A candle starts burning when it is brought near the mouth of a jar containing hydrogen because it reacts with oxygen in the air and starts burning as hydrogen is highly combustible in nature.
But it extinguishes when pushed inside the jar because there is no oxygen inside the jar.