I was watching DS9 just now and it occurred to me: apparently in the future they have solved the problem of people having the same name. When talking via communicator you never hear "Sisko to Smith" and two different people try and respond. We've all worked in the place with two Bens or three Steves and there is confusion, but not in Starfleet.
The only logical conclusion is that the Federation assigns everyone a unique forename and surname at birth. Either that or you cannot be admitted to Starfleet if they have someone with your surname already.