I think it is a lottery if you get lasting battery or not. I have an almost two year old iphone and over the time i charged it with a 5w charger, the ipad charger, wireless charging and a fast charger (on iPhone just 7.5w). Now i got 89% battery health and i never used this battery optimization option it has included.
I think heat is the biggest factor. Large OS updates always take a few percent away and a hot summer, better said each time the temperature is high enough to make your phone autodim and give a shutdown warning does even more harm.
And over the years i found that phone batteries in most cases only last about 2-3 years when used daily. It's sad that they are all glued in and in most cases you don't get new replacement batteries, just old batteries who were produced years ago to replace them.
I think with nowadays hardware the only reason for most users to buy a new phone is the degraded battery. Anything else works pretty good, it's a shame to throw something away only because of this battery problem.