You are thinking of the new price. I mean second hand value. In mint condition a phone from a few years ago is almost worthless. If it has scratches, a small crack or a dirty charge port it isn't worth anything anymore. You can buy the same model without the defects (and a reasonable battery) for less than the battery swap costs.
Old phones are refurbed and sold. New screen and battery and it’s often as good as new. A 5 year old iPhone 11 with a new battery and screen is great value at maybe $200. It’s important that the battery replacement done at those shops is easy enough otherwise the used phones become waste rather than refurbished. But whether my mom can replace the battery I don’t feel is very important.
A very clumsy person can replace the battery of a flashlight or a radio with greater success rate than a repair shop disassembling a phone and looking into your personal information while you are stranded by the side of the road unaware of the forest fire and the alien invasion while you struggle with HN withdrawal symptoms.
If we assume a batter needs replacement, that is likely to be years after a new phone. A years old used phone with an old battery will usually have a bad battery too, though. It is more about whether older hardware is worth it to invest with a new battery in the first place.