Because although your ip class might allow tens of thousands of possible hosts, a standard ethernet segment can only cope with about 1000.
Ok, so assuming you know how internal ip addressing works (e.g classes, host octets and network octets) then we can skip wading through all of that crap. If you don't know that stuff, look at suggested reading.
Ok then, so we know that computers don't see ips as decimal numbers like we do (e.g 172.16.80.0), nope it sees that in binary! So for the computer to tell the network octets and the host octets apart, it uses something called a subnet mask .
Each ip class has a default subnet mask, so a class B ip (e.g 172.16.80.0) will have a default subnet mask of 255.255.0.0. This is because the subnet mask uses the first 16 bits to identify the network.
In binary this would look like:
11111111 11111111 00000000 00000000
This kind of address can also be noted as /16, so 16 bits identifies the network portion of this ip address.
Right so that's default subnet masks sorted right? Well sometimes we have to go beyond defaults and start customizing them!
Well if you have a regular Class B address you'll have 65,534 addresses available to you, that's great right? Won't need any more than that?
Unfortunately a standard network segment can only support roughly 1,000 network hosts. That's not very efficient!
So with a class B network for instance, I don't want to waste addresses but I want to stay a Class B network!
What do I do? I subnet!! Yes that's right, I use the following: