In particular, Snow Leopard will do this when connected to modems which have certain IPv6 implementations. Lion (or later) doesn't have this problem, but since IPv6 likely isn't currently of any use to you, for now you might as well configure your current OS install to ignore it.
While disconnected from the problematic network (turn your modem off if you have to), click on your wifi / Airport icon at the top right of your screen then choose the last option on the menu (to enter network preferences).
In there, select the Airport card on the left, then the Advanced button at the lower right.
On the next page, choose the TCP/IP tab up the top, and set the dropdown next to "Configure IPv6" to "Off". Click Ok then the Apply button that was beneath that, close the window and rejoin the network.