https://bitcoin.stackexchange.com/a/49201
What walletexplorer does is called address clustering. When you spend bitcoins, your wallet will take input from several txouts belonging to several addresses depending on amount to be spend. So walletexplorer works on a simple heuristic:
If two addresses appear as inputs in any given transaction, they belong to same user
More detail about this method can be seen in this paper by Reid and Harrigan (https://arxiv.org/pdf/1107.4524.pdf). Of course, this method will fail in case of mixers and coinjoin transactions. There are advanced ways to even detect transaction that go through mixers, but I don't think wallet explorer does that
To find name of wallets it can scrap forums like bitcointalk, some addresses are tagged publicly in blockchain.info, also it can has bots trade on major exchanges to get their addresses.
and the link to the paper which looks quite interesting, although i'm not entirely sure how on-topic it is.
Excellent comment, thank you for explaining!