The history of railways goes back a long time. Evidence has been found to support the existence of wheeled vehicles which were pulled by horses and men way back in the time of the Roman Empire. There used to be grooves in the limestone roads which did not allow the wagons to go off track.
The first iron rail tracks were made in 1825 by Stockton and Darlington Railway, that linked the town of Darlington with the town of Stockton-on-Tees, which helped the miners transport coal from the mines to the port.
However, the discovery of the steam engine happened before that. But these engines were used to power cotton mills, and not railway carriages. The first steam train was built in 1804 by Richard Trevithick. However, the first commercially viable steam train was built in 1812.
Steam trains typically have a horizontal fire tube boiler with a firebox which is situated at the rear end. In front of this boiler is a smoke box which has a chimney protruding towards the top. The steam is collected from the boiler into a perforated tube or dome which is above the water level.
This steam then passes through a throttle or a regulator valve into the cylinders of a reciprocating engine. The pistons inside the engine push the wheels via a connecting rod and crankpin. The engine valves are controlled via a set of rods and linkages, that are called the valve gears.
The valve gears are adjustable, and help control the direction and cut off. This cut off determines the proportion of the stroke of the pistons, which in turn controls the amount of steam that is allowed into the cylinder. Steam is allowed from either end, making the pistons double acting.
In a typical two-cylinder steam train, one cylinder is placed on either side of the train. The steam then provides four strokes of the piston per revolution, which translates to two strokes per cylinder.
The first stroke of the piston is towards the front, while the second is towards the rear end. Each stroke of the piston moves the wheel for quarter of a turn. This boiler and these cylinders rest on a frame, and this frame rests on the axles. These axles are mounted in bearings, which move upwards and downwards in the frame.
This mode of transport was also considered to be reliable and safe, compared to traveling by wagons or horse carts.
In the later years (1940s), steam trains were replaced by diesel-based trains, which in turn were replaced by gas turbine electric trains in the 1950s. The latest technology uses magnetic levitation, where electrically-powered trains float above the rail without wheels.
Nowadays, making model steam trains has become quite a hobby for people who have a lot of interest in its history. You can even find kits to make model steam trains available in the market.