Above all, baking powder acts as a leavening agent. It's a mixture of a carbonate or bicarbonate and a weak acid which is used to increase the volume and lighten the texture of baked goods. Most people are also familiar with an alternative - baking soda which can be similarly used. Especially when you're ready to get your baking on and realize you're out of baking powder. But there is a difference in the chemistry behind it.
Baking soda, or better known as sodium bicarbonate, reacts with acidic components in batters, releasing carbon dioxide, which causes expansion of the batter and forms the characteristic texture and grain. Many forms of baking powder contain sodium bicarbonate combined with calcium acid phosphate, sodium aluminium phosphate or cream of tartar.
All chemical leaveners raise and aerate batters and dough by expanding the air bubbles created in them through mixing, beating, whipping, stirring and kneading. These millions of bubbles are trapped in the batter by the gluten structure formed and are enlarged by the leavener, either triggered by moisture and/or heat. In most cases you want to balance the leavening system to achieve a neutral pH.
Getting back to baking powder, it also includes components to improve the consistency and stability. The most important additive is corn starch, although potato starch may also be used. These days, most baking powder sold is double acting. This means that the first leavening occurs when baking powder gets wet– like when you combine the dry and wet ingredients in the recipe and the second leavening occurs when the baking powder is heated.
When the mixture dissolves in water and the temperature is raised, CO2 is released according to the equation:
NaHCO3 + H+ (from the acid) → Na+ + H2O + CO
Baking powder took over the role that yeast had years ago and the reason is obvious – it acts instantly while yeast takes longer, usually two to three hours to produce its bubbles. The chemical reaction that produces the carbon dioxide bubbles occurs immediately upon adding water, milk, eggs, or another water-based liquid ingredient. The proteins in eggs become irreversibly denatured when exposed to heat (i.e., the proteins unfold and cannot refold into their original shape). These altered egg proteins essentially give the liquid foam a solid structure, allowing it to hold its shape.
Now that you understand how baking powder works, you can understand two things you often see in recipes:
Many recipes instruct you to mix all the dry ingredients together and then add the liquid. That keeps the baking powder from reacting until the end of the mixing process.
Many recipes tell you to mix only briefly -- just until the ingredients are moistened. That minimizes the escape of the gas from the batter. If you were to stir for a long time, the reaction would end and the stirring would have allowed the bubbles to escape.