It's pretty simple... They buy up failing companies that they feel they have a reasonable chance of bringing it to profitability.... Since these companies are on the verge of closing its doors, Bain buys them foray a discount.... They bring in consultants and cut the fat, make the companies leaner and more efficient... Once they are back to profitability, they resell the company to the highest bidder (at a profit of course)
Now if they bet wrong and the company still goes south even with their best efforts they salvage as much as the assets as possible to cover as much of the losses as they can... As long as they are successful more than unsuccessful to cover the losses.