Usually, Pokémon belonging to the departed are given to people that they've formed close bonds with. However, cases of pokémon randomly ending up with a rival or complete strangers are not uncommon, meaning that they can practically end up with people just because whoever sends them to other people thought it'd be "amusing".
text