> But lifetime is evidently not as long as the device lasts, as we see with Microsoft. Plenty of XP machines are still alive out there and they have long been out of support.
This will vary from jurisdiction to jurisdiction, but where I live, "lifetime" is defined as the period of time in which a product is reasonably expected to last.
Talking about "XP machines" is a bit weird, because you're really talking about two different products there. You can very easily install whatever OS you want on there, so it's not an "XP machine", it's a machine and then a copy of XP.
In that specific case, the expected lifespan of a desktop computer is probably on the order of a decade. Maybe you'll have to replace a component or two (particularly HDD) before then, but you wouldn't expect to need serious repair work prior to that. But also, you wouldn't feel cheated if it died after 11 years.
The lifetime of the Operating System is another matter entirely. It's probably reasonable to make the case that the OS's lifetime is infinite, given that software doesn't degrade in the same way physical components do - if a non-networked program is broken in 2021 it was broken in 2001 as well (assuming you're running the same functional hardware, which isn't Microsoft's problem). It's also totally reasonable to make the case that the OS's expected lifetime is similar to the lifetime of the hardware it's going to be installed on, and I think this is probably the stronger case.
But whichever of those you side with, it doesn't really matter. If you buy a washing machine and it breaks after 2 years, you're entitled to either a full refund, or a replacement. If you opt for a replacement, the company doesn't have to send you the exact same model of washing machine, just something that's equivalent. Similarly, if there's a bug in Windows XP that renders it broken (e.g., a critical vulnerability that makes it impossible to enable network connectivity without getting your machine compromised), then Microsoft can just go "here's a copy of Windows 10, go buck wild". Even if you operate under the idea that software does not have a lifetime, Microsoft are still providing updates for what is fundamentally the same product (Windows). That it's not specifically Windows XP isn't really a problem in terms of their legal responsibilities.
Now, could you call Microsoft up right now and finagle yourself a free copy of Windows 10 just because there's some unpatched vulnerability in Windows XP? I'm not sure, but I reckon there's a chance they'd do it just to get you off their backs. It's not like there aren't millions of pirated copies out there anyway.
> how much [support] are [Apple] legally/contractually required to provide currently?
The expected lifetime of a phone is lower than that of a desktop computer (for many reasons), so I'd say around 5-6 years per device. The software/hardware distinction mentioned above doesn't really exist for devices that Apple sells seeing as they actively try to stop you from installing any software that they don't explicitly approve of, so that would cover both hardware defects and software defects.
At an absolute minimum it would be 3 years, as if Apple tried to argue otherwise you could very easily point to things like their environmental impact reports that assume a lifespan of 3 years per device (and even describe this as "conservative"!).
That said, as far as I'm aware Apple typically goes above and beyond their legal support requirements for software on their devices. They did get sued where I live over warranty periods (they were claiming that customers needed to pay extra to get warranty for more than 12 months, which is absolutely false), but that was in relation to hardware.