Why should Confucius and Mencius take their names according to their genealogy?

It was a habit in the past. Every family has a genealogy, and then every generation in the genealogy will have a specific generation. When the generation is named, the generation will join the name, and then choose a favorite word to join the name. Not everyone's name can only be called the word of the generation. Otherwise, there are n people in the same generation. Does everyone have a name? It's impossible