In order to put out a fire, one of three things must be removed from it: heat, fuel, or oxygen. Knowing this, firefighters don't always use water to put out a fire.
Ask an adult for permission before lighting the candle!
The baking soda and vinegar react to make carbon dioxide, a gas that is heavier than oxygen. As it 'pours' out of the bottle, it pushes the lighter oxygen away from the candle. The fire, now deprived of oxygen, can no longer burn.