Your iPhone has not been hacked, but it is possible that one or more of your accounts has been compromised. Here are the instructions to Change your Apple ID Password and Set or Change the Passcode
Change your Apple ID password - Apple Support
Set a passcode on iPhoneApple SupportOfficial Apple Support › guide › iphone › ios
If this is too difficult for you, please make an appointment at the Apple Store or take the phone to an authorized Apple service shop for in-person help.
You can find a list of authorized service shops in your area using this link: Find Locations