You may have seen a thing called a candle-snuffer, which is shaped like a small bell. You lower the bell down over the flame until it goes out.
Some places, like churches, still use candle-snuffers to reach the really tall candles, but why should a candle-snuffer work? Why doesn't the flame just continue to burn underneath the bell, no matter how flat you crush it? The answer is air.
Fire happens when you have atoms such as carbon and hydrogen in the candle wick linking up with oxygen atoms in the air to form molecules, such as carbon dioxide. Every time a new molecule is formed, energy is released. This is the energy that we see as light and feel as heat in a candle flame.
One way to stop the candle from burning is to let it exhaust its supply of carbon and hydrogen. You can do that by just leaving it alone until all the wax is melted and the wick is reduced to ash. No more wick, no more flame.
A faster way is to deprive the flame of its oxygen. That's what a snuffer does, by making a barrier between the flame and the air. No oxygen also means no more flame.
You can try it yourself.
Light a small candle on a table and then place a large glass upside down over the top of it. Make sure that the glass is tall enough so that the flame doesn't damage it. After a minute or so, the candle will go out. Too much oxygen inside the glass has been used up. Snuff!