When it finds two queued players that are a match, based on the player profile data it will pick one of the players as the server and will then notify the game clients that a match has been found.
Do I need a server to make a multiplayer game?
Some games can manage without dedicated servers. If youre building a game thats mostly player-to-player interaction, without a ranked competitive system, you may not need servers at all. You can play by yourself, on a local network, connect to servers hosted by other players, or host your own server.
Are World of Warcraft Private servers illegal?
Playing on the fanservers, which are also known as Private Servers for World of Warcraft are not illegal for players. But it does go against Blizzards ToS and Blizzard EULA. Running and owning a wow server is a grey area, but can be argued to be illegal as running a private server is a copyright infringement.