For water heaters, the warranty duration is an indication of approximately how long the included anode rod will last before it needs to be replaced to preserve its protective qualities. Since almost nobody replaces their water heater's anode rod, the number of years listed on the warranty can actually be taken to show about how long the unit will last. For example, a 6-year-warranty unit will probably have a warn-out anode rod in 6 years, so by year 7 or 8 it might leak if not replaced.
Longer warranties on glass-and-anode-rod units usually point to more and better anode rods. One aluminum rod would be the minimum (4-year warranty) while two magnesium rods would probably be the best (12 year warranty).
This implies that you can make your water heater last much longer than the warranty duration simply by replacing the anode rod(s) every such-and-such number of years, and this implication would be correct.
Or you can buy a unit with a stainless steel or plastic interior tank and no anode rod at all, most of which have a lifetime warranty. They're not much more expensive than the glass-lined tanks with aluminum or magnesium anode rods. The HTP/Westinhouse Everlast and Rheem Marathon are two such products.