In Safari Preferences, Homepage is grayed out in General tab. Same with Google Chrome and Firefox browsers. Thus, you cannot change the homepage. This was a new type of malware trick to take over home and search pages. Instead of just replacing homepage, malware creates custom Profiles in System Preferences. Profiles is typically used by a large corporation and schools to provide common settings for your Mac.

First, use Malwarebytes Anti-Malware app to remove all malware plugins and apps. Then, select System Preferences, click Profiles. Click on profile (See picture below.) It shows the settings. If you see any website address not known to you (e.g. weknow.ac in the picture), delete the profile. Don't delete any other profiles provided by your company or school. Restart. Go back to Profiles (it could be gone by now if you had malware profiles only) to make sure it is gone. Now, you can change the homepage in your browser.
Profile 1
Mystery solved.