If you're on a LAN (like on your home network or corporate network), chances are you going out to the internet through a router of some sort (in a home network this could be your WiFi router connected to your ISP's modem). This router will probably have
NAT (network address translation) enabled that will allow what your talking about.
In a nutshell what happens is the router has a 'NAT table' that keeps track of what internal traffic is mapped to what external traffic. In this way multiple users are able to surf the web behind a single public IP without interfering with each others sessions.
I hope that can help out.