Your situation may be as simple as needing to re-apply your AppleID
password (such as used to login to this ASC discussion) or it may be
more complicated. To get a free or paid app, you need the password
entered in App Store to verify. ~ And a record of active account there.
{RE-reading your thread I see you already made an error so this factor
is working to protect you from who you may not be, trying to use your
device or your AppleID without verification.}
The two-factor authentication -or- verification is a code that would be
supplied to fill either four-digit or six-digit blanks in onscreen form...
•That's one example of what else you may need to supply, plus
your AppleID password. ~ If you login to ASC with your email, use
that secret password and it's usually a basic means to get apps.
• Two-step verification for Apple ID - Apple Support
A later verification is more demanding & more secure, this may not
be what you are asking about just now. -- But in case it is related,
this will be something to sort out and consider learning about.
At some point with device iOS and macOS systems, you may be asked
or required to update your passcode or use a two-factor scheme; and
may have already made security Question+Answers as part of that.
{I've only 4-digit code on an old iPad iOS9.3.x, and a newer iOS iPhone
with iOS11.2.x is totally different than my older iPhone with 10.3.x;
older phone and Mac OS X 10.11.6 have these new things happening
to my corner of Apple World. I've not created six-digit pass-code yet.}
Check these. You may need to use the iForgot link and then wait - days.
Mac OS X 10.11.6 is where Mac started two-factor with six-digit code.
•Two-factor authentication for Apple ID - Apple Support
•Get a verification code and sign in with two-factor authentication - Apple Support
iOS 10.3.x is where iOS Devices were able to use more than 4-digits.
And if you go there, this may help you out when or if you lose access:
Recover your Apple ID with two-factor authentication account recovery - Apple Support
Be aware if you do commit to this six-digit code regime there would be
a need to also have 'trusted devices'. Such as an iPhone, or some other
device or accepted secure phone.
A verification code is different from the device passcode you'd enter to unlock
unlock your iPhone, iPad, or iPod touch. see details & options here:
•Use a passcode with your iPhone, iPad, or iPod touch - Apple Support
•You may not have this situation (yet) at all. IF you're only asked for your
AppleID password in order to get a free or paid application, that's not the
same as a six-digit secure code, nor the four-digit one. ~ Try your Apple
password such as you used to login to post here.
So you may have any one or combination of things going on.
Without standardized understanding or explanation: a guess.
While I've been tripping over keys with a real keyboard (no stylus
on iOS device) someone with better skills & info may have replied.
PS: The information you need is probably here now, but my window to
edit this mess is going to time-out now; before making a clear answer.