By setting a token standard like ERC20, it allows every developers to follow exactly a standard protocol which in return enable their respective development to communicate with each other exactly the way they wanted. Most importantly it creates interoperability.
The standards function in the ERC20 looks like totalsupply, balanceOf and some others. totalsupply allows the contract to calculate and return the total amount of the token that exists in circulation. Whereas balanceOf allow a smart contract to store and return the balance of the provide address.