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.

v.

"instruct, discipline, teach," 1540s, probably from earlier sense of "draw out and manipulate in order to bring to a desired form" (late 14c.), specifically of the growth of branches, vines, etc. from mid-15c.; from train (n.). The meaning "to travel by railway" is recorded from 1856. Related: Trained; training.