This is exactly what happens in cars. Usually, you have an 8 year warranty for your battery.
Yes, a phone is smaller. Less space and weight. But 5 years are less as well. The electronics can track everything, shut the phone down if it's too hot (and not when it's so hot that it's in danger to burst into flames like it is now). Adjust the charging speed by temperature. Do not charge the battery to 100 %. ...
All things the manufacturer can influence.