Why does a Toggle's OnValueChange execute when the isOn property is changed?

Trying to debug a weird execption being thrown while enumerating over a collection.

I have a menu that’s procedurally generated from a json prefs file that is loaded into a dictionary.
At start, the dictionary is enumerated and a menu item Toggle is generated for each item and it’s value is set accordingly to what the json file says. My loop stops prematurely because of an Invalid Operation Exception that happens while trying to set the Toggle state after it spawns. The error explicitly says that my collection is being modified during the loop, but I’m not directly changing anything.

I learned that just by setting the isOn property, any function that is listening to OnValueChanged does get called which is why this Exception is being thrown accedentally.

/// MenuController.cs

      foreach (KeyValuePair<string, bool> name in filter) {
         var go = GameObject.Instantiate(togglePrefab, filterWindowContent);
         var tc = go.GetComponent<ToggleControl>();
         tc.SetName(name.Key);
         tc.SetToggle(name.Value);
      }


/// ToggleControl.cs

   public void ToggleAction () {
      /// NOTE:
      /// Do not use while enumerating over the collection.
      /// This will modify the collection and throw an exception during the loop.
      /// Why is this being called from OnValueChanged without interacting with the Toggle?
      // MenuController.instance.filter[valueName] = toggle.isOn;
   }

   public void SetToggle (bool enable) {
      toggle.isOn = enable;
   }

I’ve already figured out a work-around by programmatically setting the listening function after the initial enumeration is done. I’m just bringing this up cause I’m very annoyed that this is the only UI element that calls its listening functions when it’s value is programmatically changed. Means I can’t set the Toggle’s action in editor this way.

You should be easily able to iterate the collection with an index, right?

var keys = filter.Keys;

for (int i = 0; i < filter.keys; i++)
{
  var key = key[i];
  var thing = filter[key];

/// etc
}