Government contracts typically fall into two primary categories:
As one can deduce from the names, a fixed price contract is just that - the vendor is given a certain amount of money, and and imposes fines and penalties if the desired bridge, software, space ship, whatever isn't delivered on time. The company that accepts this bet believes that it can deliver the good or service, plus a reasonable profit, for the fixed amount. Since the government's procurement policies often require acceptance of the lowest bid that it believes has a reasonable chance of successfully executing the project, it follows that this optimizes the tradeoff between risk and price.
The downside, of course, is that for unknown costs, many vendors are unwilling to to strictly abide by a fixed fee contract, and instead wish the ultimate risk to be borne by the customer, hence the "time and materials" form of contract. In order to entice vendors to take such a risk, they must either agree to reduce the risk or extend the profit. As such, even a fixed fee contract may not arrive at the lowest price but technically will arrive at the lowest cost, since other factors (including risk) are part of the cost even if they are not part of the price.
By definition, however, a fixed fee contract pushes the entire burden of a cost overrun onto the vendor. In exchange for this risk, a fixed fee contract will most likely entail a higher price than doing it ones'self.
Hybrids exist in which a fixed fee is guaranteed, but a certain amount of the risk is mitigated by a T&M contract.