It could be different in other states, but in Florida, a sale on the courthouse steps is awarded to mtge company, other lien holder, or IRS, or sherriff, or property tax if delinquent for more than two years.
Focusing on mortgage, the mortgage company does not necessarily take title to a foreclosure but has the catbird seat in the courthouse sale. The advantage is they do not have to put up any funds where another bidder must post 10% with the court.
Typically they will bid up to the amount of the indebtedness and if the bidding goes higher they step aside and get paid off by the proceeds. Any excess then goes to other lienholders or the forclosed owner.
They don't want to bid any more than they have to because certain costs they will incur are relative to the price bid.
When the mortgage company ends up in title it is because the debt exceeded the bidding or if they accepted a deed in lieu of foreclosure.
For an explanation of the short sale process (and my opinion) here is a link to my previous post