..And the same thing can happen on a Mac.
The only way this can happen on a mac is if you set up your system to always operate with root authority, which would be stupid. Most Mac users don't even know how to do so. Also Mac OS X doesn't operate well when set up this way.
For a virus to do what it wants to do it needs root privileges, so the system must be operating with constant root privileges. Mac by default requires the user to enter their root password to authorize root functions or to install items that operate at that level.
Also, if something tries to run at that level and its operation was not initiated by the user, Mac OS X will ask for root authorization. Its pretty hard for a virus to do much given how Mac OS X operates.
Internet security companies have been trying to find a hole in this for quite some time (ie OSX.Leap.A) which spread like a virus but was shut down as soon as it wanted to do something that required root authorization, hence, it couldn't do any harm.
Windows is riddled with viruses because the administative account user functions with constant root privileges by default and items can operate at the root level without being initiated by the user and without authorization by the user. Windows does not operate well when it is set up to function like Mac OS X.
I am not an authority on this stuff. So if you see any flaw in what I have said, please let me know.