ramzax,
Typically, soon-to-be graduates of US medical schools (4th year med students) apply for internships (first year of residency) via the Electronic Residency Application Service (ERAS). Based on an ERAS application, programs will invite candidates to interview.
After the interviews, each candidate enrolls in a system called the National Resident Matching Program (NRMP), which places Rank Order Lists (ROLs) from both programs and candidates into a computer. The computer matches programs and candidates at their highest mutual ranks. Once a match is made, both programs and candidates are contractually obligated to hold and fill the position for which the match was made.