I created the registry key you suggested, but still the problem persists. I am on Office 365 running Windows 11 with all the latest updates.
The username/password combo is not wrong, if you press OK a few times on the error box that appears, it will finally login, only to randomly fail again later.

The problem appeared sometime within the last 10-15 days, at first it was happening with the SMTP outlook server, the problem with the SMTP server resolved itself after a few days but now same problem happens with the IMAP outlook server.
I've been troubleshooting it for at least 12 hours, also spent 2 hours last night with Microsoft level-1 tech support through Quick Assist, they couldn't find a solution so they escalated it to L2 but I'm sure they won't be of any help either because I am almost sure it's a Microsoft problem. Something must have changed on the IMAP server and/or the end-user client (Windows PC) through windows updates (something that probably has to do with authorization), and the problem started appearing.
It was also a problem with Thunderbird, and it seems to have been fixed when the user enabled Oath2 authorization in Thunderbird. I was also experiencing the problem with Thunderbird and enabling Oath2 authorization fixed it ! There's no such option in Outlook for windows.
Just posting this in case MS techs need further info on troubleshooting the problem. Keep in mind that the Outlook app for android and the outlook webmail work without problems. I'll just stick to Thunderbird for the time being, until this is resolved.