Yes, but after Gen II there was a second secret ID number, so the game would reconize them.
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. -Bulbepedia
And before Gen II, there weren't many people playing Pokemon, so it didn't matter
Hope This Helped :D