early 14c., "a drawing out, delay," later "trailing part of a skirt" (mid-15c.), also "retinue, procession" (mid-15c.), from Old French train (fem. traine), from trainer "to pull, draw," from Vulgar Latin *traginare, extended from *tragere "to pull," back-formation from tractus, past participle of Latin trahere "to pull, draw" (see tract (n.1)).
Train of thought first attested 1650s. The railroad sense is recorded from 1820 (publication year, dated 1816), from notion of a "train" of wagons or carriages pulled by a mechanical engine.