Regardless of what many people believe, Macs can catch viruses. If you want to keep your Mac safe, use security programs such as Malwarebytes which not only protect against malicious attacks but also give real time scanning against ransomware and other attacks. It offers ad blocking and a VPN to secure browsers as well.