Nothing of the kind happens. The smoke is going in the same direction as the train, but so much more slowly that it seems going backward. When the smoke leaves the engine’s smokestack it is poured into the mass of air through which the train is pushing its way. The air resists the progress of the train, but it resists the smoke far more because it is so light. If the train were traveling forward in a vacuum, the smoke would move along with the train at the same speed.