The 1st Octet already specify the network class (1-127: A, 128-191: B,
192-223: C etc.). A, B, or C implies the number of octets for network
(respectively, 255.0.0.0, 255.255.0.0, 255.255.255.0), which
automatically tells you how many hosts is allowed for each class of
While this was historically true. This hasn't been true for years. Years ago 126.96.36.199/8 was given out in pieces to various ISPs. (I believe this was mostly to cable providers.)
Even when it was true for network assignments, netmasks were necessary for internal networks to simplify routing. Efficient routing of a network like 10.0.0.0/8 requires subdivision into smaller networks. This may be a simple scheme using /16 and /8 subdivisions, but is more likely to be classless subdivision. Larger subnets make more efficient use of address space (over 99% of a /24 is available for devices, while only 50% of a /30 is available.
The local network is routed directly from the device, while other addresses are passed through a router. Hosts with multiple interfaces may be connected to networks of different sizes.
For sub-nets without multi-homed hosts a /24 contains more addresses than is required. Most routers I have worked with have 24, 48, or 96 ports and can be supported with /27, /26, or /25 sub-nets. This allows some extra addresses for DCHP and/or multi-homing. Organizations may standardize on allocating sub-nets of /24 or /23 for routing.
Since a IPv4 address already gives the information of the network and and host, why do we >still need a subnet mask?
Many devices use a default netmask of /24 which in many cases matches the size of the local subnet (localnet) assigned to the router. This is equally applicable to classes A, B, and C. Unless the subnet size matches the default subnet a netmask is required.
If addresses are specified using CIDR format, the netmask and network can be calculated from the address. If not the network can be calculated from the address and netmask. It is not possible to reliably calculate the netmask from the address and network.
Providing a gateway (router) address for a subnet allows the default route to be configured allowing routing to addresses outside the subnet.