With Windows, it was a known variable until Windows 11. I have a lovely i7-7700 I built in early 2017 here, and it's officially unsupported in Windows 11 and will stop getting all security updates in 2025. So that's zero major OS upgrades and 8 years of minor/security updates. (Although, I suppose some people would count the feature updates for Windows 10 as a bit more than 'minor' updates, but I don't think they're as major as Apple's annual updates) Oh, and just to make the insult worse, a stupidly-low-end one-year-newer laptop is supported. And if I go and replace it tomorrow, who knows whether what I buy tomorrow will be supported in Windows 12 or it will be again, one year too old. It's important to remember that now that they stopped charging for OS upgrades, Microsoft only makes money when they sell HP/Dell/Lenovo/etc a shiny new OEM licence. (And yes, the irony is that with a few rather-well-documented tweaks, current versions of Windows 11 run just fine on every 64-bit machine that runs Vista/7/8/8.1/10, i.e. the NT 6.x family, regardless of CPU/TPM/etc. But Microsoft reserves the right to break such unsupported systems or not give you any security updates at any time...)
When you compare how Apple treated my now-traded-in mid-2014 MBP with how Microsoft treated my i7 7700, if anything, it makes me want to buy more Macs. I'll take a predictable 4-6 years of major OS upgrades followed by 1-2 years of security updates over being told my 4 year old high-end Windows desktop "doesn't meet the performance and reliability expectations" for Windows 11. That being said, I have a lovely 2-month-old refurbished mid-2020 Intel iMac whose life expectancy I am starting to get a little anxious about...