Not all companies and corporations are successful. Many of them, including those with the smartest business plans and the best managers, struggle to make money, and some of them actually lose money. This happens to public and private companies.
What causes the problems leading to a company losing money can be wide and varied. A company could have missed a paradigm shift in its industry that caused competitors to take business away from it. A corporation could have decided to enter a new line of business that resulted in disaster, leading to huge losses. Or a business could have acquired another company, taking on debt and other financial obligations that it is no longer able to meet.
These are just a few examples of why a business goes bad. When a company in dire financial straits gets into a position where it is no longer able to pay its bills and loans in a timely manner, it often files papers with the court allowing it to continue operations but reorganize the money it owes, making those payments more manageable. This is called entering bankruptcy court.