I read an article about this recently, and this part of the new wave of advertising. It is currently a heated debate b/c most users (including myself) feel that this is essentially hacking your computer to advertise to you.
The article did not explain exactly how this works, but the general concept is this: Advertising companies scan networks and deliver the ads directly to your desktop. I can only assume that they do this by scanning for open ports commonly associated with chat programs like Messenger, ICQ, AIM, etc....
According to the article most firewalls will block this.
I tried, very unsuccessfully to track down the article, but I'm not exactly sure where I read it. I tried all my usual sites archives with no luck. It really sticks in my head that it was cnn.com. If I manage to find it, I will post in this thread.