Loans are an asset on the banks balance sheet and can be sold like any other asset.
This is literally what this thread is about, people's debt getting passed on from the bank to someone else
It doesn't work the other way around: if your end of it is a liability (your loan/mortgage/whatever), nobody wants to buy that from you, because it's worth a negative amount of money, it's a burden, a liability. Companies want to purchase the other end of the deal, because it's what makes them money: it has a positive value.
So depending on the the loan, you might be able to buy it so you can pay it off at a discount.