1. Use Malwarebytes for Mac to remove malware.
https://www.malwarebytes.org/antimalware/mac/
Download, install , open, and run it by clicking “Scan” button to remove adware.
Once done, quit Malwarebytes Anti-Malware for 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.
2. Reselect your search engine, reset homepage, disable all extensions and test.
Set your Home Page. https://support.apple.com/guide/safari/set-your-homepage-ibrw1020/mac
Choose a search engine. https://support.apple.com/guide/safari/customize-your-search-ibrwe75c2a3c/mac
Turnoff or uninstall extensions.
Section: Manage extensions: https://support.apple.com/guide/safari/use-safari-extensions-sfri32508/mac
Restart your Mac.