Legendaries show up in the wild like any other Pokémon, just rarely. Only one can be out in a server at a time, and if it gets away, it comes back to that server until somebody catches it. Catching it is the only thing that ends the chase.
The ones that run
Raikou, Entei, Suicune, Latias, Latios, Mesprit and Cresselia bolt after a failed throw. They keep the damage you did and come back to the same channel.
One at a time
After one shows up, a server waits a while before a different legendary can appear there.
Mythicals
Mythical Pokémon don't spawn in the wild. You earn them by finishing Special Research stories in /specialresearch. The one exception is Phione, which hatches from a Manaphy Egg.