Both the subnet mask and the wildcard mask essentially do the same thing. They are used to define the network portion and the host portion of a particular address. This is useful when defining the IP address of an interface, the range of addresses included in a particular subnet, the range of addresses participating in a routing protocol, as well as the range of addresses that are to be filtered using an access list. For IPv4, subnet and wildcard masks are used for many operations.
When using the subnet mask, it is always ANDed with the address in question to determine the associated range. When using a wildcard mask, it is NANDed. The results are exactly the same.
So why do we sometimes use one and sometimes the other? It all has to do with convention. Way back in 1985, when access lists were first used for IPv4 addresses, they were implemented using assembler language. It turns out that it was much easier to code a NAND operation than an AND operation. So the wildcard mask was used to define access lists.
For various other operations where these functions were necessary, they were either implemented in a more “user friendly” (subnet mask) manner or in a more “code friendly” (wildcard mask) manner depending on the vendor, the coder, and the CPU resources available.
Over the years, it turns out that the wildcard mask was used more for some features, while the subnet mask was used more for others. For configuring hosts, the subnet mask prevailed, because user friendliness was paramount. For configuring network devices, the winner was not so clear cut, so we use both for different features.
Today we don’t have such coding restrictions, so technically, both can be used as an implementation method. Even so, some features, such as the network command for various routing protocols will accept both wildcard and subnet masks. Some features, such as IP address configuration on an interface will only use subnet masks. Others still will use only wildcard masks. What is used today is largely due to the choices that vendors have made, and their attempt to make the CLI environments as familiar as possible for the professionals using them.
I hope this has been helpful!