How Does a Trick Candle Relight Itself?
A normal candle can sometimes be relit by touching a flame to the trail of smoke rising from its wick. A trick candle uses the same stream of fuel but carries its own hidden source of ignition.
When an ordinary candle burns, heat melts the wax near the wick. Liquid wax rises through the wick and vaporizes. It is primarily this wax vapor, rather than the solid candle, that burns in the visible flame.
Blowing out the candle removes enough heat and burning vapor to extinguish that flame. However, the tip of the wick can remain hot and glowing for several seconds.
A trick candle contains small particles of magnesium within its wick. Magnesium is a highly reactive metal when divided into fine pieces. The glowing wick can become hot enough to ignite exposed particles after the main flame has disappeared.
The burning magnesium produces tiny sparks. These sparks ignite the wax vapor still rising from the warm candle, rebuilding the flame that was just blown out. Magnesium located farther down the wick does not ignite immediately because the surrounding wax limits its contact with oxygen. Fresh particles become exposed as the candle continues burning.
The candle can therefore repeat the performance several times. Blowing harder may only scatter sparks or briefly remove the flame again. The safest way to extinguish it completely is to soak the burning end in water and make certain that no glowing material remains.
The candle is not preserving its original flame. It carries a series of tiny chemical matches inside the wick, each waiting to restart the normal burning process.
Source: ChemMatters: Demystifying Magic Tricks, American Chemical Society - The Chemistry of Candles, Royal Society of Chemistry

Tschanüff castle, in the background parts of the Piz Spadla mountain, in Switzerland
Source: By Hermann Hammer