You cannot change account association for an app. If you downloaded an app with an old account, you must be signed into that account to update the app. What you say about updating the app with a different account is not possible. You were either signed into the account that downloaded it, or you used yet another account to download it for the first time with that account.
This is one of the reasons why Apple suggests you erase devices between owners (each Apple Account = a different owner), and you stay with a single account unless you really know what you are doing and truly need a separate one for a completely independent persona. When you do that you are better off owning a second iPhone or whatever.
You will have to decide how you want to reconcile this. It's either going to be go with the account that downloaded them originally, or risk data loss. Well, I guess there's also not updating the app at all. Note that Apple won't let you sign in and out of accounts frequently: Refer to this support article about a message —> View and remove your devices that are associated with your Apple Account for purchases - Apple Support
‘When you try to associate a device that was previously associated, you might notice a message that says, “This device is associated with another Apple Account. You cannot associate this device with another Apple Account for [number] days.” You might need to wait up to 90 days to associate the device with a different Apple Account.’
The above statement is new in 2024. It used to be Apple only talked about restricting app downloads and streaming for 90 days.