You have a mobile app (Android/iOS) that requires the user to sign-in. The mobile app offers in-app purchases. A user makes an in-app purchase while * signed in as X on the
From reading through the docs relating to in app purchases on iOS the purchase is always tied to the device account, or Apple ID in the case of iOS.
Restoring purchases prompts for the user’s App Store credentials
Source
That's just the way it is and we have to work with it.
One possible solution would be to mark users of your app who have bought an in app purchase as "members" or "subscribers" in your own back end.
I am simply assuming that you have your own back end because as far as I know you need to have one to verify the in app purchase, and you also mentioned logins.
Then when a user goes to reinstall the app after they have deleted it, they then sign into the app, your app checks with the back end to see if the current user is the one who purchased the in app purchase, if they are, then restore the purchase, if not then don't. Then going forward you just show and hide the paid content based on whether or not the signed in user is the one who made the purchase,