Viruses are just computer programs, or sometimes Scripts. All computer programs and scripts are written to work with specific hardware configurations. And just like you can’t put Microsoft word for windows on a Mac and have it run, you can’t put windows viruses on a Mac and have it run. By the way, the same is true in reverse. Viruses that are written for macOS will not run on windows.

That said, there are ways to write computer code so that the application is cross platform. There are only a few of these type of malware found out in the wild.