Why do steam engines sometimes make a 'chuffing' sound while static?


Wonderfully Old Fashioned
I'm not sure if it's the way I put in the search bar but I found the answer to this question AGES ago somewhere, and I can't remember what it was.

So why do Steam engines sometimes make that chuffing sound as if their moving while static?

(All I ask for is the answer btw, make it as simple as possible)
I am not sure about the steam engines in trainz, but in real life a steam loco under steam and standing still sometimes lets out a beat when the reversor is thrown from mid gear to fwd or reverse, probably because steam was trapped and escapes to exhaust when the valves move.