I have run into this problem any number of times in designing and testing scenarios and I wonder if anyone has seen it or has a cure.
Here's the situation:
Long(ish) player train (20 cars or so) crosses over an automatic switch. All is fine until the last few cars of the train - then the switch throws and causes one of the trailing cars to go a different way. The end result is a derailed train and a message "train derailerd due to switch set against train" (or something like that). Usually the only solution is to find another place to cross over the tracks. I don't see this with manual switches, and it seems to be a timing thing. In at least one case I can "beat" the switch by speeding up and getting all the cars over the switch before it changes.
There's no apparent way to pre-set the direction of an automatic switch, and inserting a waypoint or "go via" instruction doesn't change anything.