A mapping is a hash table from key to value. Every possible key exists and returns the zero value until written, so there is no length and no way to iterate.
mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance;
If you need to enumerate holders, keep a parallel array or emit events and index them off chain.