Many people seek protection under the bankruptcy code because they have been sued. If you default on a credit card debt or unsecured line of credit then the creditor can sue you. Also, you can be sued on the deficiency of a repossessed or foreclosed secured loan. If you fail to timely respond then the creditor can take a default judgment against you. Or, if the creditor proves to the judge that it is more likely than not that you owe the money, then a judgment will be taken against you.
The creditor can record the judgment and either file a lien against your property or get a writ of sequestration and take money out of your accounts.
When you file a bankruptcy, the automatic stay provision in the bankruptcy code will cease all such activity. The bankruptcy almost always stops the litigation and discharges the debt.