Some computer operating systems do allow malware to infect themselves and some OS will block the infection by how the OS is written and run. Most malware seems to be slightly modified versions of existing malware. Setting the download preferences to all ways ask me before installing or running a downloaded program appears to protect computers from infection. Only going to known, safe websites is also very good at avoiding malware.