What you need to understand is that tokens on Ethereum only exist inside the token contract of that token. They are not “sent out” to wallets as Ether is. All sending and receiving of Token X is done by manipulating Token Contract X internal state.
So to your question, how Etherscan knows about the states. If they read Token Contract X, they will know how much each address is credited. The information Etherscan reads is the current state of the token contract, and Etherscan somehow selects what tokens they show to their users and what tokens they don’t.
If you create Token Y with Token Contracy Y and allocated each Ethereum address 100 Y Tokens, it will not show up in Etherscan unless they chose to show it (by including Token Contracy Y in their visualization).
So back to how you distribute Token Y. You either create the token with an internal state from the start where each address xyz have n amount of tokens, and then you don’t need to spend the gas to modify the token contract after the initialization. But no transfer can be done after creation without invoking the Token Y Contract, since the state is stored there.