A very mangled version of what happened
NASA started by sole sourcing their cargo transport to the ISS to Kistler, who were developing a two stage reusable launcher.
Kistler by this stage consisted of a lot of ex-NASA people who outsourced all the actual rocket stuff to various giant aerospace companies. Costs escalated and delivery dates rolled to the right in traditional aerospace style.
SpaceX filed a protest about sole sourcing the contract - federal law mandates competitive bidding except in certain circumstances. After winning, their bid won - along with Kistler. So, a two horse race.
Then Kistler ran into a slight problem. They ran out of money before actually finishing anything. They couldn't find the half billion dollars they needed to actually build something. So they went bankrupt. Note that the extra money they needed to finish was far more SpaceX (or Orbital) spent in total on their systems.
So down to one bid. So NASA made some noises and Orbital came up with their bid to be the second supplier. And got a better deal (more money for less stuff) than SpaceX, by the way.
Both Orbital and SpaceX have only received money form NASA in competitive contracts based on actual work done.
To many (like me) the bankruptcy of Kistler was a sign of why the COTS program was a better way to go - I you fail, you fail. What a shame. Not.
The Ares I project collapsed due to the fact that the stupid design wasn't fixable - the vibration from the solid first stage ranged from I-cant-see-the-instruments (really!) to Ive-been-shaken-to-death (literally). By the end of the program, it couldn't lift an Orion capsule all the way to orbit because of the weight of the shock absorbing systems required to reduce the vibration. Not to mention an 18G escape tower system that used a rocket the size of an IRBM to... fail to escape the debris cloud if the first stage went boom...