This is literally insane. Apple has had declining standards in design and software quality for quite some time, but this one really takes the cake.
I faced this problem and it was infuriating. Tried to fix it on my iPhone and it kept saying it didn't work even though it was 100% the right security code. Once I got to work I tried to fix it in my iCloud account here. https://appleid.apple.com/account/manage
This resulted in the same thing, but. Then, for some reason, I decided to try changing my Apple Store account, to see if it was different. It was. Different address, different cards. I changed it here - https://secure1.store.apple.com/shop/account/setup - and it worked.
Everything seems fine now. This is crazy. Please fix this. You have $100 billion dollars in the bank. Please fix this. This is trash.