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.
In general I think this is less of an issue today, since usb-C is both generally great and very small, so you can just use it. But, if thinness came at the sacrifice of common connectors like USB-A (or like HDMI), the opportunity cost of standard connectors might be lost.
I'm ignoring that like many of apple's ports are just better than USB-A to focus only on the waste argument here though.