I think you mean the TARP/TALF programs.[1] They were loans with very specific conditions and costs. Meaning banks had to pay interest on those loans to the U.S. government, which was definitely above the U.S. government interest rates. As far as I remember, Goldman was one of the first Wall Street banks to pay those loans back (including interest). The programs ended up being profitable to the Treasury and by implication, the American tax payer. See the linked website for more details.
The reason some banks started using the money from those programs to buy up government debt, is to make their books more solid, or in other words, make the money market believe that they won't go bankrupt any time soon and start lending them money again. For example, if I have $5000 and bet all of it on horse races, and then immediately ask you to loan me $100 more, you'd be sceptical. If, on the other hand, I bet $2500 on horse racing, put the other $2500 in a deposit box, and ask you to loan me $100 for cab fare, the deal would seem a bit more solid, right?
There is another argument, that international banks profited hugely from the AIG bailout, and that the bankers were unprofessional for not foreseeing a possible AIG collapse. That is only partially true. Yes, the bailout money allowed AIG to honour its contracts with the banks.
But AIG was an insurance company and the things it sold to banks (Credit Default Swaps) were insurance against selected companies going bust. For example, if I loan Apple 50 billion dollars, I want to insure the whole deal for the very slim chance Apple goes bust. In 2008 a lot of companies started to go bust, hence AIG had to pay out a lot. So much, in fact, that it would go bankrupt.
If I change the words, and say that American machinery manufacturers insured their factories against possible fires with insurance company A, but due some freak accident all the factories started burning, so the government had to step in and bail out company A, so they could pay out the insurance policies. Doesn't seem so preposterous, does it?
I really like your explanation, and especially the final analogy. Sets the tone that we should be concerned with figuring out why all those factories are burning down. That shouldn't happen naturally. But you would generally not get in the way of the fire trucks putting the fired out: urgent and immediate help is needed, even if it's costly. Besides, the bill gets sent to the company in the end.
GS uses the capital to buy government bonds with governments own money to make literally riskless profit."
I have zero sources for this, so if I'm wrong please say