First check that the stores aren't already using the new ID.
In iOS/iPadOS: Go to Settings > [your Apple ID] > Media & Purchases. Sign out of the current ID and sign in with a different one.
In Ventura or later: First, quit Settings. Then, in App Store, choose “Sign Out” in the Store menu, then click on the “sign in” button that appears in the main window. You can then sign into the other account.
They probably are already using it which is why you are encountering this problem. This is caused by using more than one Apple ID which is contrary to Apple's advice. Read this support article about Apple ID Frequently Asked Questions --> https://appleid.apple.com/faq
"How many Apple IDs do I need?
Just one. Use the same Apple ID everywhere you sign in to ensure that all your Apple services and devices work together seamlessly and you can access your personal content from all your devices."
Items downloaded with one ID are permanently tied to that ID. If you paid for them, look into using Family Sharing to share with an old ID. In your case though, the other ID is inaccessible. You will have to delete the current app and redownload it using your current account. This may unfortunately involve the loss of data if the data are tied to a particular Apple account. I don't know how it is with WhatsApp which I have but have never used (reminder to self: delete that app).
Keep your Apple account up to date and only use one account unless you truly want a completely separate and unconnected persona (some use a second one for business but this usually entails having multiple mobile devices since a device can only be signed into one main account at a time and it is not easy changing between them).