I had this problem this evening, and the answer (in my case) was: you can't do anything, if your OS is too out-of-date.
My friend had a Macbook with Mac OS 9.5.
She could log into iCloud.com with her Apple ID and password, but the App Store on her Macbook refused to accept the password.
The solution would be to upgrade to the latest OS... but her Mac said there were no available updates to her OS, even though Catalina was shown in the App Store... but, of course, we couldn't download it, as it wouldn't accept her password.
Long story short, I had to download Catalina on my Macbook, create a bootable USB stick with Catalina on it, wipe her hard disc, and then App Store would finally
accept her password.
This is... really... really... bad.
Anyone who uses that infamous phrase "It just works, with Apple" really isn't right....
Found answer. You have to add at the end of your password the 6 digits code you'll receive in another apple device.
Here it is correctly explained -> https://developer.apple.com/forums/thread/117451?answerId=716214022#716214022