As per the many, many other "My iPhone is hacked" posts here, the possibility of it being actually "hacked" (i.e. someone that is not you can do anything on your phone that you can) is remote in the extreme. Governments with access to multi-million dollar hacking assets have been known to do it (and Apple is actively working so that even those are not possible), the (by far) most common way that someone's phone is "hacked" is simply that another person (friend, family member, ex) knows your screen unlock code. In many cases, it's not even that. They receive a text or email saying it was hacked when it wasn't.
Some posts here are that "No matter what I do, they get into it again!" which cannot be possible because even you, the authorized user, can lock yourself out quite easily. Close your eyes and enter a random screen unlock code*. Now try to get into your phone, Not happening. They say "I even changed my Apple ID and password and that didn't work". Well, log into your Apple ID yourself, close your eyes, enter random characters as the new password then log out and try to get back in*. Not happening. So how is the "hacker" doing it? They're not. If the authorized user can lock themselves out so easily, how can you not lock them out?
Point is, people are throwing around the word "hacked" way too much. For example, every time my elderly mom gets an unexpected email (i.e. phishing), she tells me someone "hacked" her email. No, it isn't. Don't open it, simply delete it and forget it. Other people say they're "hacked" if they see a glitch in an app. That does NOT mean your account has been compromised.
If something unexpected happens on your computer or iPhone, simply post your question in a support forum or contact Apple support. 99.9999 (and a lot of other nines) percent of the time, it's a simple matter to fix it and very close to never involves the phone being "hacked".
Do not share your password, do not share your screen unlock code, and do not believe everything a scammer tells you in a text, email, or phone call. You get notified that an expensive item you ordered is being held by the "processing center" and all you have to do is pay some money to clear it? Did you order that item? No? Then is that not a very clear sign this is a scam? Yes, it is. It's a huge sign in big red bold letters.
*Do NOT under any circumstances do these things. You WILL be locked out of the account.