Fundamentally, you can’t. The same as how a gas car can’t avoid a $5k transmission or engine replacement. Cars being totaled due to their most expensive part failing isn’t really a new thing or unexpected. Beaters are sold for scrap literally every day because it’s not worth repairing them.
All cars have a limited lifetime. For ICE cars, that’s on average around 12 years, and things often start going wrong around ~150k miles. You can get particularly well-maintained cars to last much longer, but most people don’t. Classic cars are mostly a hobbyist thing for a reason.
The question isn’t “will the battery eventually die”, its “will the battery last 15-20 years while still having 60-80% of its initial capacity?”
And based on real-world data, the answer appears to be “yes, unless you have a lemon or really abuse your battery.” Lemons are also nothing new.