No, that's not what happens. Banks buy Treasury bonds or the same reason they loan money to you and me. They generate profit through the collection of interest. Banks buy and sell debts as part of the normal course of business. When banks buy debts, they gain profit (so long as the debt payments are made). When banks sell debts they gain cash on hand that they can then potentially loan out again, or use for other methods of investment. In short, banks are constantly buying and selling assets, all part of their complex methods of trying to maximize their profits and staying solvent.
Banks also borrow money. The Federal Reserve is the lender of last resort from whom banks may borrow in their desperate hour of need in order to remain solvent.
When banks sell Treasury bonds, they do so on the open market. The Federal Reserve, through its normal operations, buys bonds on the open market. The Federal Reserve achieves profits from its operations, but since it's a non-profit entity those profits have to either be spent at the end of the year, or dumped into the Treasury at the end of the year. When the Federal Reserve buys Treasury bonds on the open market, the interest on those bonds then goes to the Federal Reserve. While this may mean that that interest makes it back into the Treasury when the Fed remits its profits, all that means is that the federal government is able to leverage careful and skillful securities trading to minimize the actual amount of interest that is paid out on the public debt.