Please take all these steps.
1. Use the latest release of MalwareBytes for Mac to remove malware/adware.
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. Disable all extensions and test.
Disable or uninstall extensions.
Section: Manage extensions: https://support.apple.com/guide/safari/use-safari-extensions-sfri32508/mac
3. Choose a search engine.
Delete all text in the Smart Search field, click the magnifying glass , then choose a search engine from the dropdown list.
https://support.apple.com/guide/safari/customize-your-search-ibrwe75c2a3c/mac
4. Set your Home Page.
Choose www.apple.com as Home Page.
https://support.apple.com/guide/safari/set-your-homepage-ibrw1020/mac
Restart your Mac.
Set Google as your Home Page.