To use your Apple ID with the App Store & iTunes Store you usually need a functioning payment method in your account.
On a Mac;
Open the Music app
Choose the iTunes Store
Choose Account in the Music Quick Links on the right side of the store window
Sign in to your Apple ID
Add a payment method to your account details
On an iOS device;
Open the Settings app
Chose your Apple ID
Choose Payment & Shipping
Add a payment method to your account details
M1 Mac mini, macOS 12.0.1; Watch, series 5 GPS/cellular, watchOS 8.1; iPad Pro 2nd Gen, iPadOS 15.1; iPad Air 2, iPadOS 15.1; iPhone 12 Pro, iOS 15.1; TV 4th Gen, tvOS 15.1; HomePods, audioOS 15.1 and Airport Express w/ Airplay 2