You can protect your Mac from malware by only allowing apps that come from the App Store or from identified developers.
App Store: Select to allow only apps that have been downloaded from the App Store.
App Store and identified developers: Select to allow apps only from the App Store, and from developers identified by Apple.