>>12144171In anime logic it has to be something like this, because of that episode where they discover a sunken ship and the captain's pokémon come out. Granted, they're ghost pokémon, but I have always been under the impression that they weren't ACTUALLY ghosts, just live pokémon with certain powers.
As far as the games go, I've assumed it was a mixture of;
>>12144182>>12144178This explains how NPCs know what pokémon we're carrying and can "talk to them" at a whim.