How long can a battery possibly last

I recently sold my 2008 BMW 135i. It had the original battery in it. I sold that car since it was getting older and the maintenance is absurd. You have to get a new battery “coded” which is basically programming the car and letting it know you installed a new battery and it’s not being stolen. Stupid.

I replaced the bmw with a 1998 viper GTS two months ago. The battery was dead last weekend so I bought a new one and went home to swap them out. The bad battery had a sticker from 02/19... only 3 months old and it was K.O.’ed. The bad battery was an Oreillys brand and I had bought the EXACT same battery by luck. The Oreillys manager ended up giving me some money back without me asking when I took the core in.