How long your battery lasts depends on what brand it is, what climate you livel in , and weither it has a 2 year or 3 year or 4 year warranty. How many miles you have on the car makes no difference. Here in the Texas heat I'm lucky if I get 5 years out of a battery. Sometimes you get lucky , I just changed the Battery in my 2000 Thor motor home with 88,000 miles on it. Its a Ford 305hp V10. Date on battery was from Aug 2003.
General advice is to do a battery hydrometer test and make sure the battery post are shiny and clean. You can get a tester at any parts store. They look similar to a coolant tester. To clean the posts , get a special wire brush from the auto parts ,you remove the clamps and clean the contact surfaces of the clamps and post.pay special attention to the positive post because it really gets corroded. make sure they are tight when reconnecting them. also clean the battery top which can accumulate crud between the posts and maybe short out the battery, at least in theory.
I changed the battery in my daughter's 2014 Corolla when it hit 4 years old. My experience in Rav4's was that the OEM Toyota batteries last 4-5 years, and since she doesn't live near me, I wanted the peace of mind knowing she had a good battery. Also, Advanced Auto was having a 20% off sale, so the timing was good.
My previous car was a 2002 Chevy Prizm (Corolla in drag). The battery seemed to die one day at 10 years of age - but by turning off the A/C and all other accessories, I was still able to drive home, then to the store to get a new battery. (I loved that car. It never stranded me once. It was 17 years old when I wrecked it.) IIRC, the replacement battery had significantly more Cold Cranking Amps.
Of course, with this car, I won't let it go anything like 10 years before replacing it - I just got lucky.