Switching two train station from on to off and from off to on in the same gametick lets the train ignore its timetable sometimes - depending on which station is closer.
I dont know if this is intended, but in my opinion the train should follow its timeline if there is a trainstation availible, even if you turn a station off and another station on in the same gametick.
Turning a station off is an immediate call to the train to re-path because the station it was going to is no longer valid. That will change the current stop to the next stop in series which is valid. Then turning a station on is an immediate call to any train that is in the no-path state to re-path.
That's working as intended. To do it otherwise would lead to even more problems.
If you want to get ahold of me I'm almost always on Discord.