Coming from an electrical background myself, I can see how latching a relay would work - but I think there's an all mechanical answer out there, though it would require custom parts and such.
I keep thinking of marble runs - there's a device that does the motion we require, passes one direction, while setting itself for the opposite motion.
https://www.youtube.com/watch?v=oP1eIqCFhMo
Also one sprung switch wouldn't work, for the reasons listed.
But a Wye of sprung switches sends the trolley down both the legs in question - the problem here is, it doesn't go all the way to the top on one path.
Assume all switches are sprung to the right. The star indicates what I would normal consider the end of the line, from which the 2 routes diverge. As you can see, leaving from the bottom left, the trolley doesn't go to the star before heading to the start.
EDIT
I think I got it. We mentioned putting a switch button on the COMMON bumper-
Instead, put switches on the end of routes A and B, and wire it so it sends power to flip the switch the opposite way. Trolley goes down route A, hits bumper/switch, power sets switch for for route B. Trolley rolls though the switch, hits bumper and reverses, goes down route B. Repeat.