You need to provide more details. Your phone was not hacked. There are some possibilities that may have happened, but without more details a solution is not possible.
- Someone may have talked you into signing out your Apple ID and signing in with a different one. This does not mean your phone is hacked, just that you were scammed.
- You may have fell for a phishing scam and gave someone your Apple ID Password. With that information a person can go online and change any information you have in iCloud, such as photos, and those changes will be reflected on your device. Your phone has not been hacked, but your account has been compromised and changing the password will resolve the problem.
- You may have given someone the Passcode to your device and they were able to make changes without your knowledge. Change the Passcode and keep it secure to prevent any future problems.