The match is an algorithm and this describes the actual algorithm and how it works:
http://www.nrmp.org/res_match/about_res/algorithms.html
And that pretty much is technical, but answers none of your questions. There are a lot of factors that play into where you match. If you go into a less competitive specialties with lots of programs you have a much better chance of matching in the location that you want(just by pure numbers). Also sometimes programs seem to rank you lower if they don't think you really want to move there, so demonstrating ties to the local would be helpful, but wasn't necessary in my case.
Most people in my med school (I'd say greater than half) stayed in state. Mainly 'cause they wanted to. You can also do away rotations your fourth year to programs you are considering. So if you really wanted to, it is possible to match really far away from your med school (I did so without even trying

).
That being said, read Panda's blog. He's gotta lot of good info. And he should leave it up (hint hint if he's reading).
PS Panda I love the blog and my favorite ones are "Tomorrow Will Suck" and "Clinical Evaluations"