Go step by step and test.
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
Change Extensions preferences in 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. Reset Homepage. Change your homepage in Safari on Mac - Apple Support
6. Check proxies
System Preferences > Network > Advanced > Proxies
Deselect any proxies if selected.
7. Restart the Mac. Relaunch Safari holding the Shift key down.
If this doesn’t help:
Download EtreCheck, run it to see if there is any adware installed or not.
https://etrecheck.com
Click “Free download” button,
Open Downloads folder, click on it to open, and then select ”Open”.
“Choose a problem” from the popup menu box, and then “Start EtreCheck” in the dialog.
Click “Share Report” button in the toolbar, select “Copy report” .
Paste the report when you reply.
Note: This is a diagnostic test.