A subnet mask is a string of '1' bits followed by a string of '0' bits, making a 32 bit number, which we express as four byte values for convenience (e.g., 255.255.255.0 is really 11111111 11111111 11111111 00000000).
All of the bit positions where there is a '1' in the mask combine to form a network number. All of the bit positions where there is a '0' in the mask form a node number within that network.
We subnet when we have a requirement to add a router to our network. Since the routerrequires a different network number on each side, we take one or more bits of our node numbers, and claim that they are part of the network number. This allows us to have multiple network numbers to keep the router happy, without exceeding our allocated range.
A station can talk to other stations with the same network number only. To talk to stations with a different network number, the station must talk via a router, one of whose ports must be on the same network number as the station.
When we subnet, we lose addresses. In the formal definitions of the subnets, each subnet has a network address (all zero bits in the node address), and a broadcast address (all ones in the node address). These addresses may not be used for stations. Additionally, when we subnet, we lose the first subnet and the last subnet of the defined subnets. The reason for this is that first subnet has its network address equal to the defualt network address for the unsubnetted address range, and the last subnet has its broadcast address equal to the broadcast address of the unsubnetted address range. So if you use two bits of subnet, you get two subnets, not four, and you have wasted 1/2 of your address range.
If you are using private address ranges like 192.168.0.0, just use another class C (192.168.1.0) rather than subnetting.
Hope this helps.