Sometimes the original meaning of a word is surprising and then almost immediately not surprising at all. Such is the case with train.
The original English word train, which existed centuries before the locomotive, referred to the part of a gown that trails behind the wearer. We don't see these trains much today outside of the occasional wedding, where they sometimes appear in the wake of a bride. Long ago, trains also featured on cloaks and robes unrelated to nuptials.
The word train has been part of English since the 14th century—since its Middle English days. Like most things fashion-related, it's French in origin: it comes from Middle French by way of Anglo-French, which is the French spoken in Medieval England after those Norman invaders settled in. The Anglo-French trainer meant "to draw, drag."
The word train continued on its merry way through the centuries. It developed other meanings on the tail (or train, as it were) of the clothing one. (It refers still, in fact, to tails, especially of peacocks and comets.) But from the clothing it seems next to have landed next as a reference to a group of people who follow behind an important person—they were like the clothing train, but on legs. Train also referred to a moving line of people or vehicles or animals, and from there to the particular vehicles and the like that provide various services to a combat unit. It entered the truly metaphorical realm to refer to an orderly succession, as in "train of thought." And the line of black powder that in cartoons leads an unfortunate character to a soon-to-explode cache of dynamite—the "fuse" as it's more often called—also had the word train applied to it.
It wasn't until a couple decades into the 19th century that the word began to be used with today's most common meaning. It had to wait, of course, for the thing to be invented. But only sort of: the earliest modes of transportation that are recognized as railroads were built in European mines in the 16th century; they used cars pulled on tracks by men or horses. The tracks these ran on were called train roads and trainways by the turn of the 19th century. Earliest known evidence of the word train referring to linked mining cars doesn't appear until a bit later. And it wasn't until the construction of the first railway in 1825 that the word train as we now most often use it really started to become established.
Perhaps the most surprising thing about the word train is that there is an entirely unrelated English word train that most of us have never heard of. The obsolete train meaning "scheme, trick" also dates to the 14th century and traces back to the Latin word tradere, meaning "to hand over, deliver, betray." And it has nothing to do with clothing or comets or cartoons.