The track consists of two iron rails and wooden ties between the rails. The rail is held in place with a round spike. A bed of gravel holds the wooden ties. The wheel has a lip so it won't fall off the rail. Fire is produced in the firebox which burns wood, coal or oil.
Hot gases released by the combustion enter tubes in the boiler.
The water in the boiler is heated at the hottest location, on and around the firebox, and produces steam. The steam pressure builds in the boiler as the water expands and is then released into the cylinders to move the pistons. The exhaust steam from the cylinders goes up the blast pipe and joins with the smoke from the fire to go up the smokestack. That is when we see the big puff, and hear the swhooooosh. What happens inside the steam boiler.