From the Super Mario Wiki
Trains[page number needed], also referred to as N64 Express, are stage obstacles in Kalimari Desert in Mario Kart 64 and Mario Kart 7. They are red-and-black coal-powered steam locomotives with five passenger cars in Mario Kart 64, and three passenger cars in Mario Kart 7. Both trains in the course travel along an elliptical track that the player crosses twice; at each crossing lies a crossbuck and a set of two lights that flash if a train approaches. The player flips over if they hit any part of the train, including the passenger cars.
In VS mode for two players in Mario Kart 64, there is only one passenger car, while in the Grand Prix, as well as in VS mode for three and four players, all cars - including the freight car - are removed. In the multiplayer mode for Mario Kart 7, one of the trains is absent.