Considering the highest possible ID number in any game is 65535, it's not uncommon for more than one player to have the same ID Number.
However just because two player's have the same ID Number, the game will not necessarily recognise the two players as the same player.
As from Generation III onward, there is a second, secret ID number, different from the visible one. This number exists purely to make sure that even if two Trainers share the exact same name and gender and the exact same Trainer ID number, the game will still recognize their Pokémon as coming from different Trainers.
Usually, this number cannot be viewed; however, certain cheating devices can be used to view it, and there are also calculators to determine it. It also comes into play along with the normal ID number and the personality value in determining if a Pokémon is Shiny.
If two different Trainers have the same Trainer name, identical ID numbers and identical hidden ID numbers (a 1 in 4,294,967,296 chance if the names do not differ), the game will recognize the two Trainers as the same, so the Pokémon are not considered to be outsider Pokémon.