Battery life is affected by various factors. Batteries in warm places lose charge faster than ones kept cool, and the varying quality of materials means cheaper ones often fail before more expensive types. Although AA batteries look alike, the chemicals inside them can be different, with great effects on lifespan.
Batteries produce electricity by chemical reactions between two electrodes made of different materials, such as zinc and manganese oxide, and another component called an electrolyte. With use the electrodes corrode and wear out, and the battery dies, but this corrosion happens far faster in batteries that use an add electrolyte than those with an alkaline electrolyte.