Baking powder is a mixture of baking soda (sodium hydrogencarbonate) and tartaric acid, a weak edible acid. When it is heated or mixed with water they react:
sodium hydrogencarbonate + tartaric acid → sodium salt of tartaric acid + water + carbon dioxide
The acid supplies H+ ions, and each NaHCO3 that meets one gives a molecule of carbon dioxide. It is this carbon dioxide that makes a cake rise and become soft and spongy.
Why it keeps in a dry tin: an acid shows its acidic behaviour only when water is present, because only then does it produce H+ ions. In a dry tin the tartaric acid and the baking soda are just two dry solids side by side, so they cannot react, and the powder keeps.
What went wrong in the damp kitchen: moisture from the air dissolved a little of the powder, so the acid produced H+ ions and slowly reacted with the baking soda inside the tin. The carbon dioxide formed simply escaped into the air. Over several weeks most of the baking soda and tartaric acid were used up in this way. When the old powder was finally added to the cake mixture, there was very little left to react, so very little gas was produced and the cake stayed flat. The fresh sample fizzes because all of its reactants are still there.

The industrial routes out of common salt, including the baking soda in baking powder.