Alkaline and nickel-cadmium AA batteries corrode when the caustic material inside leaks onto the steel casing. This happens as a natural part of the battery's life cycle, but can occur prematurely if the battery is exposed to high temperatures.
Alkaline batteries contain potassium hydroxide, a caustic substance that is not used up as the battery discharges. Because the potassium hydroxide remains after the battery's useful life is over, dead batteries carry the risk of corrosion and leakage. They must be disposed of in accordance with local laws.
Rechargeable nickel-cadmium batteries also contain potassium hydroxide, and have the same leakage risks as alkaline batteries in high temperatures. Nickel-cadmium batteries carry an additional risk: because they are not discarded after use, they are more likely to be left inside of devices during long-term storage. When batteries leak inside of a device, the potassium hydroxide corrodes plastic and metal parts and damages the device.
Other types of AA batteries do not have the same corrosion risks that alkaline and nickel-cadmium batteries do. Lithium batteries do not corrode, but they do carry a risk of fire and explosion. This is due to the reaction between the lithium in the batteries and moisture in the air when the metal shell of the battery is opened.