Android being open source isn’t the problem.
However with Android, companies sell 100s of millions of devices to consumers that are more concerned about price point than updates. There just doesn't seem to be the incentive for OEMs to care about it, if the majority of consumers refused to buy devices based on old OS versions or ones that didn't get updates, those devices wouldn't get made.
Open source isn't the differentiator, IMO. OEM fuckwittery is. Just as Dell can junk up this $3,000 laptop with shitty drivers and shell extensions that are markedly worse than what Windows offers natively, so could other Windows OEMs.
The major difference here I think is that until the recent era, MS wasn't competing with those OEMs so they had little reason to try to one-up MS and every reason to leverage MS for as much of the update infra as possible. For the last 5-10 years, with the Surface line, Microsoft has been increasingly encroaching on the top OEM user base and some are fighting back by trying to outdo MS (and failing).
But I don't think anyone is putting the right blame here on Android. It's not the OEMs not serving enough software updates, it's that in many parts of the world, a 10 year old device can still connect to the network and the carriers are OK with that. That device, even it it was from Apple, would not be getting updates that late in its lifetime but large swaths of the world aren't so fucking hung up on phones as jewelry that they update every year, or even every two, or even every 5. Those ancient Android phones in Bangladesh, they're working just fine for their users and even Apple wouldn't be serving them any better with software updates.