How do self-relighting (trick) birthday candles work?
In normal candles, as you blow them out, you will see burning embers in the candles, which vaporises the wax and thus causes a ribbon of paraffin wax to rise up (this looks like a wisp of smoke). These embers are often not hot enough to light the ribbon of wax, so the candle goes out. 

However, in trick candles there is magnesium put in the wick. When normally burning, the liquid wax shields it from oxygen so it cannot ignite. However, when the candle is blown out, this magnesium is able to react with oxygen (ignite) and light up the paraffin wax ribbon rising, reigniting the candle (or rather, the volatile materials above the candle). The magnesium is often powdered or in thin strips for low ignition temperature and easy ignition.

Sometimes regular candles do reignite, in these cases, the embers are hot enough to light up the paraffin wax vapour