This is a more difficult to answer as where you decide to do residency depends on various factors including where you complete medical school (state, outside of North America), how competitive is the speciality that you want (i.e. areas like orthopedics, dermatology), the types of the clinical experiences that you choose to complete during medical school (i.e. clinical rotations selected by your medical school and a few pre-clinical/clinical electives or rotations chosen by you in a specific field), and family commitments (unfortunately due to spouses, children, sick family members, etc. we do not all have the flexibility to move around compared to when we are young and single).
To make matters worse, there is a very cumbersome ranking and residency matching system where in a nutshell in all the schools and residency programs where you succeeded to reach the interview stage, you have to rank your 1st choice to last choice of selected residency programs.. Obviously, your chances improve if you have some clinical experience at the residency program that you are applying to but it is not always the case as people achieve the same experiences in other parts of the country and have better marks on interviews, references, USMLEs, or scores in medical school.
I suggest at this early stage to review the below links to learn more about how the residency matching system works. In addition, for the purposes of medical school interview and for your own career planning purposes, it is important to start asking yourself and re-evaluating over your time in medical school, what speciality or specialities am I interested in and am I willing to move away from home for another five years to fulfill my dreams of becoming an X specialist? If your answer is no, then it is important in medical school to pursue clinical experiences through individually chosen pre-clinical and clinical electives in other interested specialities where you wish to pursue residency as it gives you an opportunity to get references and network with people involved in selecting people for residency and an opportunity to see if you really want to work in that speciality and be a resident with that specific residency program.
An example that I can give you is a person that I know really wanted pediatrics residency in a university located near by home. So she got an interview and ranked that as her 1st choice. In case she did not get the spot, she also interviewed for a family medicine residency spot near by home and ranked it as her 2nd choice because she could still practice some pediatrics as a family doctor and pursue a more abbreviated form of pediatrics residency after completing family medicine residency. In addition, she interviewed at other pediatric and family medicine residency programs at other parts of the country and ranked them lower as she was not too interested to move but needed some back up options in case the first two did not work out. She ended up matching with her second choice for family medicine residency program near home and was obviously sad that she did not get pediatrics but happy to be doing some form of clinical work with children as a family medicine resident near home.
Below are the links to learn more about the matching system. It is great that you are thinking about this part of it as residency selection system can seem really vague when you are in pre-med. Also, try not to be hard on yourself if your goals regarding specialities and where you wish or program that you end up matching for residency is not what you originally thought it would be. Residency program matching can be a painful and anxiety ridden process but if you are clear about your goals and have investigated other areas for back ups then that can reduce some of the pain associated with this process.
Links for residency matching programs in North America: For United States, a Wiki page on the National Resident Matching Progam http://en.wikipedia.org/wiki/National_Resident_Matching_Program
For Canada, A wiki page on the Canadian Residency Matching Progam http://en.wikipedia.org/wiki/Canadian_Resident_Matching_Service
Side note: As a Canadian born IMG who studied in Ireland, I highly recommend that you really think carefully before choosing medical schools outside of North America as it is becoming increasingly difficult for IMGs to come back to North America for residency and it can be stressful doing residency in other countries as there are agreements to select citizens from those countries to get residency and specialist posts before international graduates. I was lucky to get a residency spot in family medicine in Canada but went through a lot of scrutiny regarding my educational credentials and clinical skill upon obtaining a residency spot. In hindsight, hang in there and have a plan b in a career that you want and keep reapplying to medical schools in North America.