Its function was to expel the air that came inside the cylinder along with the steam to prevent the engine to become "wind logged". Since the valve was non-return, how did Newcomen stopped steam from leaving after pushing out the air?
The snifter valve allowed air and some steam to escape - this did not differentiate between air and steam, just opened briefly when steam was entering. See https://en.wikipedia.org/wiki/Newcomen_atmospheric_engine
The opening on early engines was manual - but as they increased in speed this had to become automatic which led to the "Potter Cord" and later a beam with cams and tappets to control the valves. See https://www.gracesguide.co.uk/Newcomen_Engine