iPhones and MacBooks can be serviced to replace the battery.
My iPhones typically get a fresh battery around the 3-year mark, or whenever the battery health dips below 80%, and do a second tour of duty with someone in the family. In all cases so far, the OS goes out of support and apps stop working before the second battery degrades.