1. Remove unknown profiles if present.
System Preferences > Profiles
Open System Preferences, select “General and click the “Profiles” icon ( a checkmark on a gear) .
When Profiles pane opens, select the unknown profile and click the minus button at the bottom.
Section: Remove a configuration profile from your Mac
Profiles:
Use configuration profiles to standardize settings on Mac computers - Apple Support
2. Remove unknown extensions: Safari > Preferences > Extensions
Get extensions to customize Safari on Mac - Apple Support
3. Check for adware.
Run the latest release of Malwarebytes for Mac to remove malware/adware, if installed on your Mac.
For instructions: Install Malwarebytes for Mac v4 Uninstall Malwarebytes for Mac
Click the “FREE DOWNLOAD” button.
Click the “Scan” button. Once done, quit Malwarebytes for Mac.
Restart the computer and relaunch Safari holding the shift key down.
Scan for Malware again.
Additional steps if necessary.
4. Reset search engine: Customize searching in Safari on Mac - Apple Support
5. Change your homepage in Safari on Mac - Apple Support