1. Use the latest release of Malwarebytes for Mac to remove malware/adware installed on your Mac.
Install guide: https://support.malwarebytes.com/docs/DOC-1817
Uninstall Guide: https://support.malwarebytes.com/docs/DOC-1190
The installer may ask you to allow it in Security & Privacy /System Preference. Allow it.
Click the “Scan Now” button.
Repeat the scan couple of times.
Once done quit Malwarebytes for Mac.
Restart the computer , relaunch Safari holding the shift key down.
2. Additional steps, if necessary.
1. Remove unknown Login item.
System Preferences > Users & Groups > Login items
Authenticate and unlock the lock.
Highlight the unknown login item (Mac Mechanic?) and click the “-“ button at the bottom left to remove it.
2. Remove unknown and third party installed extensions if installed.
https://support.apple.com/guide/safari/use-safari-extensions-sfri32508/mac
3. Reset search engine. https://support.apple.com/guide/safari/customize-your-search-ibrwe75c2a3c/mac
4. Reset Homepage. https://support.apple.com/guide/safari/set-your-homepage-ibrw1020/mac
5. Restart the computer, relaunch Safari holding the shift key down.