Nothing to do with any railroad, the trainband was a group of citizen soldiery organized to serve as reserves in depth for the regular militia.
The term arose in the sixteenth century and lived in this sense as long as the practice of having such citizen reserves continued, that is, into the eighteenth century.
It has continued to live in attributive senses with respect to especially trained groups of people or of animals.
The word itself is merely a shortening of trained band.