It's a long story, but basically the government puts "city pairs" out for bid to the various airlines, and the winning bid (lowest price for flights between the two cities) gets the contract.
For flights not a part of "city pair" contracts, the government usually has a deal with the airlines to get an unrestricted ticket at somewhat less than usual "Y" rates.
And yes, this is for official travel only, not for personal travel.