I assume it is set up on the two device you mention. See Two-factor authentication for Apple ID https://support.apple.com/en-us/HT204915 See this section especially Set up two-factor authentication for your Apple ID. From this section, "Two-factor authentication is available for Apple ID accounts with at least one device that's using the latest iOS, iPadOS, or macOS. Learn more. You can follow these steps on your iPhone, iPad, or iPod touch to turn on two-factor authentication."
Try to generate a code from your trusted device. See Get a verification code and sign in with two-factor authentication https://support.apple.com/en-us/HT204974
“Whenever you sign in with your Apple ID on a new device or browser, you'll confirm your identity with your password plus a six-digit verification code. There are a few ways you can get a verification code. You can use the code displayed on your trusted device, get a text or phone call, or generate a code from your trusted device.” A trusted device is an iPhone, iPad, or iPod Touch with iOS 9 and later or a Mac with OS X El Capitan and later that you've already signed into using two-factor authentication.