Smoke comes from a fire. Inside the steam locomotive there is water and a fire to heat the water to make the steam. Steam under pressure provides the power to make the wheels go round. It is like the air in a balloon. Air in a balloon can move something.
Valves admit steam alternately to each end of the cylinders.
The steam acts on the pistons within the cylinders and forces them back and forth. Each piston has a rod fastened to it. This rod passes through the back of the cylinder, where it is supported by a crosshead and guide. Attached to the crosshead is one end of the main piston rod. The other end of the rod is free to revolve around the crankpin on one of the driving wheels.