The cylinder cocks on all steam locomotives are opened prior to movement in order to expel and condensed water/moisture from the cylinders. Since liquids, especially water, do NOT compress, the possibility of causing mechanical damage to the cylinder heads, pistons, and or piston rods, is very high, should there be any condensed water/moisture between the piston and cylinder heads. Once the water has been "cleared" from the cylinders, the Engineer then closes the cylinder cocks.
As added information, there were/are two different types of cylinder cocks:
1) The steam operated design of cock, is normally spring-loaded OPEN. Thus, it takes boiler pressure to CLOSE the cock, and the Engineer has a conveniently located valve in order to "turn on the steam supply" to all the cylinder cocks. The big advantage of the steam operated design of cocks is, if the Engineer happens to close the cocks a bit too soon, and there is still some remains water in a cylinder, the resulting hydraulic pressure will exceed the boiler steam pressure, and thus OPEN the cock with a loud POP. Upon hearing that POP, the Engineer will reopen the cylinder cocks until all the water is expelled.
2) The air operated design of cock, is normally CLOSED. Thus, it takes air pressure from the main reservoir to OPEN the cock. Therefor, if the locomotives air pumps are NOT running, and there is no air pressure to OPEN the cylinder cocks, and the locomotive is moved by some other locomotive, there is great danger of mechanical damage to cylinder components.