Most car battery warranties have two periods: a free replacement period (usually 1–3 years) followed by a pro-rated period. A '5-year battery' typically means 2 years free replacement and 3 years pro-rated.
Pro-rated means you pay a percentage of the new battery's price equal to the percentage of warranty used. A battery that fails at year 3 of a 5-year warranty has used 60% of its warranty period, so you pay 60% of the new battery's current price — often more than what you originally paid.
Free replacement is the only period that's truly free. Pro-rated periods are mostly marketing — you'd often pay similar money buying any battery off the shelf.
Keep your purchase receipt. Some warranties require it for any claim. The vendor's records may not be enough if you bought online or moved between stores.
AGM batteries usually have shorter free-replacement periods than flooded, even though they cost more. That's because AGM lifespan is more variable depending on the vehicle's electrical demands.