I have a game that uses mover constraints for trains, and these trains are kept on track by having cancollide parts in between the rails.
I would suggest using counterweights. Heavier trains are much easier to knock over. If you place the weights underneath the train, then they’ll be biased towards remaining upright. You also need to make sure that the guide parts have enough breathing room. Make the rails or at least their collides tall/deep to allow for movement in the Y axis without them jumping out of the rails. In the picture that you’ve shared, the rails appear extremely thin and close to ground level. I’d hope that the guides have more room than that. Maybe use collision groups to prevent the guides from colliding with the terrain and restrict the guides to only colliding with the rail and hitboxes. Also, what variety of trains do you use? Are they bodymover/force trains or simulated-wheel trains?