Apple's software support for all their devices lasts much longer than the competition, and their hardware tends to last many years out of warranty. Not always of course, but this is a numbers game, and there is a robust secondary market in everything Apple makes.
Objectively, a laptop, phone, or tablet, will have a longer service life if manufactured by Apple, than anyone else, with the possible exception of ThinkPads.
Sure, if you want more RAM or what have you, you have to buy a new computer and sell the old one. That's expensive, but all that matters with respect to the environment is total service life of a given machine, and again, as an objective matter, Apple is peerless there.
It's tempting to compare this record against imaginary competition which doesn't exist, but I don't see the point.
That's true for mobile products.
On desktop no one beats Microsoft's support time spans. Apple cares significantly less for desktop longevity.
An apple device with upgradeable parts would be even better for the environment. Apple's software support has no effect on the environmental impact of non upgradeable computers compared to upgradeable computers.