Keep in mind that hackers aren't always trying to hack specific computers. All they need to know is a system that might be vulnerable. When you visit some website then the webserver will start logging all kinds of information about who visited the site, when, where from and some indication of the webbrowser used. Now, if you use Internet Explorer then the webserver will know that you have a Windows system for sure. If you use another webbrowser then it's still likely that your webbrowser starts information about your operating system as part of it's User-agent. (Some browsers allow you to fake this information, though!)

Now, once your visit to some website has been logged, the owner of this website can check this log and filter all visits from Windows systems out of this log. He then has a list of possible vulnerable systems that he can all try to hack. As mentioned before, this is quite easy because of all the available scripting tools.

Now, the trick for such hackers is of course trying to lure as many visitors as possible to their system. This can be whatever is most popular at that moment. But they also have to be aware that if there's a lot of pages that a visitor can view then a single visitor might fill up a lot of the logs. But it actually doesn't matter what page the visitor is viewing on the webserver as long as they visit it at least once. One trick would be a simple banner on the webserver and make this banner part of other sites by linking from those other sites. For example, by adding them as part of a signature on many forums. The more hits the server gets from different clients, the more systems the hacker can start to examinate.

One other problem is of course that this could also happen with other operating systems than Windows. Hackers might also decide to target e.g. Linux systems. However, Windows systems are still a large majority of all systems that are used for webbrowsing. So that makes Windows a very popular target for attacks. It's not that Linux has less vulnerabilities. Windows is just a lot easier target to shoot at. Think of it this way... You see a mouse and an elephant. You have a huge gun and need to bring home some meat. Which would you prefer to shoot?