Because they want to hang onto the idea that Macs don't get viruses. But Windows doesn't get viruses anymore either. It's all stuff you have to be stupid enough to install yourself for the most part. But if Apple is continuing to grow at their current pace, these sorts of things will increasingly target the Mac (and their iOS devices). Code is code. Not sure why people think one platform would be immune to malicious code.
The design consideration and implementation of security will certainly affect how vulnerable an OS is. You are right that code is code, but its more that PEOPLE write code, so it is not immune to faults/security vulnerabilities.
However, a properly designed OS with security policies that are not just an afterthought will certainly be more secure than an OS which put in security in the back burner. Now I am not saying that Windows does this in particular, but because of quite a few legacy support that even new Windows include, it actually compromises the security advancements of a NEWER Windows OS.
Imagine you are at a lab where secure areas are planed and drawn into the floor plan. You have double door hallways with keycard access, elevators with level restriction, etc. And then at another lab, instead of building these features in, you just create random walls in the middle of the room, putting a sign up that says "restricted entry" with a double swing door, and giving out keycards that have full access privilege to anyone in the lab regardless of clearance level. Which is more secure?
The nature of Unix or a Unix based system is more secure is because it has security in mind first and foremost. That is why in practice Unix systems are more secure than their windows counterparts. If you remember back in the windows 3.1, 95, 98, ME days, these systems were more or less built on "consumer" mentality, so multi-user logins and other security features were spotty... with Windows 2000 and XP coming along they realized the need for this and added in "security" systems but because of backwards compatibility (say a program, number munchers) needed full root access in order for it to work (like writing to a system DLL), MS had no choice but to give access, or sandbox the application...
This is STILL the case today (XP mode anyone?) and with supporting a lot of legacy software means it's a pain in the ass for microsoft to think about all the corner cases where these security holes can exist. Couple this with the fact that it's PEOPLE who write code, you'll introduce vulnerabilities.
So after that long statement (man i'm bored at work)... You can't just say "code is code" and "But Windows doesn't get viruses anymore either" because the FUNDAMENTAL difference in a Unix Based system and a Windows Based System IS how it handles security.
Viruses/Trojans/Worms (lets not get into technicalities about how to name them shall we?) deals the most damage attaching itself onto system files and/or running as a background daemon etc. So in a Unix-based system (in this case OS X), your username/password or your user input is needed for it to even get to the place it wants to go. While in windows, it still sorta/kinda does but there are certainly more ways to access those files without so much security barriers.