Simply sign in on a device you have used with that account previously. What you are seeing is discussed in this Apple article: Get a verification code and sign in with two-factor authentication - Apple Support
With two-factor authentication you may need to verify your identity using a trusted device generating a verification code when trying to conduct certain activities. If you use iOS 11.3 or later on your iPhone, you might not need to enter a verification code. In some cases, your trusted phone number can be automatically verified in the background on your iPhone. Enter the telephone number as requested by the hint. It shouldn't matter if the number is no longer in service. Likewise it doesn't really matter at this stage if the email address isn't functioning.
The article also describes other ways to verify with a trusted device or an Account Recovery Contact. Tap “forgot” to see some of these.
If you find you can’t sign in, reset your password, or receive verification codes, you can request account recovery ( How to use account recovery when you can’t reset your Apple Account password - Apple Support ) to regain access to your account. Account recovery might take a few days or longer, depending on the specific account information you can provide to verify your identity. The post by shoeluvr13 at this link provides additional detail about the account recovery process: Activation Lockout Issues - Apple Community