Let's say someone is named John Smith applied for a job claiming that he was graduated from University X. How would an employer confirm that the applicant is John Smith, who also has the degree from University X? Wouldn't it be incredibly common for someone else to have the same name from the same department?
Most of the time, employers trust that potential applicants have the degrees that they claim they have. When applicants apply for jobs, they are frequently asked to attest to the fact that everything they are submitting is truthful. There can be enormous legal and reputational consequences to lying.
If it emerges later, for any reason, that an employee lies about a degree, they run a very strong risk of being fired and having their reputation and credibility destroyed. In some case, fraud can lead to criminal changes. Because the consequences can be enormous, most people will not lie about something like the conferral of a degree.
In situations where employees needs to verify a degree, there are many options. Employers might request a copy of a diploma or a transcript from applicants (I was asked to do this by an Academic HR department at my current university to finalize my appointment). In some cases (e.g., when applying to graduate schools) it's routine for the degreeholder to request signed and sealed copies of academic transcripts that are sent directly from the registrars to potential schools or employers. Some universities and fields have automated systems that employers can use to verify that an applicant has the degree they claim.
Although it's possible that a university or department might have multiple students with the same name, you won't have two students with exactly the same experience. Two identically-named students will not likely have started in the same department at the same and ended at the same time (information that would normally be on a CV). Registrars will often have systems in place to ensure that they only individual students can grant access to their transcripts (e.g., by requiring less public information like a password, birthday or, government-issued ID number) which acts as another form of evidence.
If an employer was incredibly skeptical, they could just ask an applicant basic things about their experience in school. Who did they take classes with? Which professor did they have the best relationship with? Then send an email or call and see if things check out.
Many universities have a degree verification service. For example:
The simplest way to eliminate the possibility of an incorrect match is to search using the student number. However, in this case the date of birth can be used as well. The surname, year of graduation, and degree are also required. Note it does cost money to check (20 CAD in this case).
There are also checking services which apply to groups of universities. Such as:
Every University has a degree verification phone number that employers can call and it only takes about 5 minutes. Just type the name of the university, degree verification into Google and the number will come up.
I just put the degree verification on my resume beside each degree. This way the hiring person can see that it is legit and they can call to verify.