In fact, in most cases good AV which is regularly updated with the latest av/antimalware definitions and heuristic analysis can protect us from our own mistakes.
That's exactly what security software is for, for prevention and not only for cleaning the operating system when it is infected with virus/malware.
Ransomware protection is work in way that such software is trying to disable access to the location where ransomware is first trying to encrypt user data. Another method is to create fake files, something like bait for ransomware, and if such files get changed in any way, security software will try to delete/quarantine ransomware.
Any kind of protection is better than none, but the paid solutions of reputable companies are my only choice when it comes to protecting my computer.