Do a Google (or better yet, Wikipedia) search on the NRMP Match. Basically you apply to residency programs all across the country. You can apply to any program you want. Let's say I want to do Ortho. I can apply to every ortho program in the country. But if i'm also interested in Ophtho, I can apply to ophtho programs as well. Then the program will look at my application and decide whether or not to invite me for an interview. After I interview at all the programs that I want to interview at (and invited me), then I submit a rank order list. I list the programs I want to attend; 1,2,3, and so on down the list. Then the computer puts every med students' lists into an algorithm, and spits out a result for (most) everyone. Then you go where it tells you to go.
As I understand it, you apply broadly (sometimes in different specialties) and see who gives you interviews. From those interviews rank your top programs in order, taking into consideration your chances (by this point almost all have narrowed it down to 1 specialty).
The programs also rank the people they interviewed. The data from all the programs is put into the computer and an algorithm compares your list to the program lists. And this is your match.
If you don't match you can 'scramble' and find a program with open spots but generally the best spots are already taken.
There is one main match but some specialties have earlier matches.