The key thing about a normal candle that is important to a trick candle is the moment after you blow out the candle. Normally there is a burning ember in the wick that causes a ribbon of paraffin smoke to rise from the wick. That ember is hot enough to vaporize paraffin but it is not hot enough to ignite the paraffin vapor. Which is what a normal candle actually burns to give light.
The key to a re-lighting candle, therefore, is to add something to the wick that the ember is hot enough to ignite. That way the ember can ignite this substance and the substance can then ignite the paraffin vapor. The most common substance is magnesium. Magnesium is a metal, but it happens to burn (combine with oxygen to produce light and heat) rapidly at an ignition temperature as low as 800 degrees F (430 degrees C) (aluminum and iron both burn as well, but magnesium lights at a lower temperature).
Inside the burning wick, the magnesium is shielded from oxygen and cooled by liquid paraffin, but once the flame goes out magnesium dust is ignited by the ember. If you watch the ember you will see tiny flecks of magnesium going off. One of them produces the heat necessary to re-light the paraffin vapor, and the candle flame comes back to life...