Is it necessary to buy flight tickets within Turkey in advance? Do the flights sell out? Is it cheaper to buy in advance? What's the best way to buy the tickets?
We have been to Turkey twice and flown within Turkey two times on each visit. We have used Pegasus and Turkish Air. We made our reservations 4 or more months in advance as the tickets are cheaper. We bought the tickets online on the airlines' website. You can sign up at their websites for newsletters with their discounted prices. The low cost tickets are sold early so it's best to check the prices as soon as you know your dates and locations.
It is not necessary to buy in advance, but I'll echo Carol's statement that flights are cheaper the earlier you book. In my experience with Turkish Air the ticket price steadily increases the closer you get to departure as more and more of the cheaper seats are sold. I've always bought my tickets for Turkish Air via the web. They also have a US-based locations that you can call (e.g. New York, Atlanta).
Tickets aren't exorbitant at the last minute, and a Turk told us that many locals do indeed buy them that way at the airport for routes with frequent service (like Istanbul to Izmir or Ankara). But, as said above, you will save by buying in advance.
You buy tickets on the website of the airline; they work the same as any other e-tickets. If you have a choice on a route, look at Atlas Jet. Not because they're nicer (all of our flights, on Atlas Jet, Anadolu Jet, and Bora Jet, were fine, with free beverages and snacks), but because they have free shuttle buses from the airports to popular destinations, saving cost and hassle. For instance, when we landed at Izmir, the Atlas Jet shuttle took us right to the center of Selcuk.