There are many ways to understand subnetting. Here is a method that I use to figure out the IPv4 network address, the first address and the last broadcast address quite easily.
The following part requires understanding of the basic concepts of subnetting and binary math.