I ran into the same issue today when we were trying to rent a movie. Thanks all that had the helpful posts in this thread, I didn't know what was going wrong!
I was initially able to get it working for the rental by turning off two factor authentication through https://appleid.apple.com/account/manage (it's on option in security settings) as mentioned by @petenixey in this post (appleTV keeps asking for appleID, password and authentication code circularly) . During the playing of the movie I had turned two factor authentication back on and the loop started again when we paused/played the movie so I had to turn two factor authentication back off.
When the movie was done I followed @NYCperson999's advice and signed off on the appleTV (Settings > iTunes Store > AppleIDs> Sign Out). Then I turned two factor authentication back on and signed in to the appleTV. After I entered the password I was prompted for the code and it took it! So far that's had it.
Although it's not what I did directly, it seems like you may just need to log off and log back in to the appleTV for it to be able to use the two factor authentication properly.