Suppose I want to deploy my smart contract in the ethereum main network as an erc20. In order for it to be an erc20 one of the requirements is balances[msg.sender] = _totalSupply; Is that right ? Why do we have to allocate ourselves all the tokens supply what happens if we just allocate 10% of the supply for example. Secondly when we deploy a token in the ethereum network is it erc20 by default ?
There's no requirements to allocate to yourself the whole supply. You can distribute it whatever you want, even you can mint as you go.
For a contract to be considered an ERC20 it has to follow EIP-20 - ERC-20 Token Standard.