First, here's the official answer from Foursquare (slightly edited by me to correct, yes, spelling and grammatical errors ):
If you've been to a place more than anyone else we'll crown you the "The Mayor" of that place.
We calculate mayorships based on the most *days* with check-ins in the past 60 days (so 2 check-ins to the same place in one day just counts 1x). Look out though, if someone else comes along who has checked in more days than you, they will steal the "Mayor" title back from you. A lot of bars and cafes no offer "Mayor Specials" - (i.e. a free coffee, appetizer or maybe a special discount to the Mayors of their venues, and sometimes just to anyone who checks in! Watch for the yellow or orange "Special Nearby" icon in your Foursquare app).
(Hint: if you want to become Mayor, you will need to have uploaded a profile photo to your account via your settings page)
Be double-sure to soak that in, because I've seen people overlook that little bit of info: no matter how many times in a day you check in to the same place, it only counts as one check in per day. Also, be sure to have a profile picture! It may help to go to the Foursquare website to set your account up rather than do it all through your app. It certainly can't hurt!
So with that said, there's something that's a bit confusing, when you check in to a place on Foursquare it'll tell you how many days until you're the Mayor of that place. Often just a day or two. This seems to contradict the official statement of the most days out of 60 days (2 months).
Admittedly, I'm still new to using Foursquare so I'd like to know the answer to this contradiction as well, so if anyone knows, please help the rest of us by posting below. Also, if you have any other Mayor tips, please do share! We'd love to make this THE informative thread on how to become a Foursquare Mayor (and keep it!).