My custom editor is working better than expected and I'm not sure why

Hey all, I’m writing a custom editor for a traffic placing tool, with the main goal being linking multiple roads together into a continuous network. Each road should connect to another road or, if it’s at the end of the map, there’s a checkbox for “Looping” which means cars will teleport to a starting point on the network.

To get this working, I have a custom editor with two main functions: In OnSceneGUI I draw a button for the start and end point of the selected lane. That means with two lanes selected, you can click on the end point of one lane and the start point of another and the two lanes will become connected. In OnInspectorGUI I draw the inspector, where each lane has a checkbox for whether it should loop and a Property Field for what lane it’s connected to. One of my recent additions was to automatically gray out the “Connection” field if the lane is set to loop (since the lane it loops to is chosen automatically).

This all works as intended, but what’s weird is if I use the Scene GUI to connect a lane to another, it automatically un-checks the Loop setting. This is actually exactly what I want, but what’s weird is nowhere do I have any logic to change the Loop setting. Here is the code for the Loop setting in OnInspectorGUI:

    EditorGUI.BeginChangeCheck();
    GUILayout.BeginVertical();
    GUILayout.FlexibleSpace();
    GUILayout.Label("Loop", EditorStyles.wordWrappedLabel);
    EditorGUILayout.PropertyField(lane.FindPropertyRelative("loop"), GUIContent.none, GUILayout.Width(28), GUILayout.ExpandWidth(false));
    GUILayout.EndVertical();
    if (EditorGUI.EndChangeCheck())
    {
        (var segment, var num) = FindConnectingLane(i);
        lane.FindPropertyRelative("segment").objectReferenceValue = segment;
        lane.FindPropertyRelative("lane").intValue = num;
    }

    using (new EditorGUI.DisabledScope(lane.FindPropertyRelative("loop").boolValue == true))
    {
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Next Spline", EditorStyles.wordWrappedLabel);
        EditorGUILayout.PropertyField(lane.FindPropertyRelative("segment"), GUIContent.none);
        GUILayout.EndVertical();

        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Lane", EditorStyles.wordWrappedLabel);
        EditorGUILayout.PropertyField(lane.FindPropertyRelative("lane"), GUIContent.none);
        GUILayout.EndVertical();
    }

And the code in OnSceneGUI:

        if (Handles.Button(startKnotUIPos, UIRotation, HandleUtility.GetHandleSize(startKnotUIPos)/25f, HandleUtility.GetHandleSize(startKnotUIPos)/25f, Handles.DotHandleCap))
        {
            if (selectedEndpoint != null)
            {
                Undo.RecordObject(selectedEndpoint.segment, "Assigned Lanes");
                selectedEndpoint.segment.NextLanes[selectedEndpoint.lane] = new Merge(ls, i);
                PrefabUtility.RecordPrefabInstancePropertyModifications(selectedEndpoint.segment);

                selectedEndpoint = null;

            }
        }

As far as I can tell, clicking the OnSceneGUI button changes the NextLanes value, but it shouldn’t do anything to the Loop value. Does anyone know why that would be?