Many bankruptcies involve continuing payments on existing loans--and in most cases, this is perfectly legal. The catch is that the bankruptcy court must be aware of what you're doing and must approve the payments. With some bankruptcies, it's part of the plan that you're going to keep making payments to your creditors, but you do it through the trustee, not on your own.
Chapter 13 Plans
To qualify for a Chapter 13 bankruptcy or "wage earner plan," you must have excess income over and above your necessary living expenses each month. You give this extra money to your bankruptcy trustee, who then distributes it among your creditors. Therefore, your loans continue to be paid. The advantage to filing for Chapter 13 protection is that each creditor typically receives less money than if you hadn't gone bankrupt. You might have had a $600 monthly loan payment to one particular creditor, and now the payment to your trustee, to be divided among all your creditors, might be $600 per month. Your creditors usually only receive a portion of what you originally owed them at the beginning of your plan, when you filed for bankruptcy. If you still owe any of them at the end of your Chapter 13 plan, the balances are discharged or erased--you don't owe the money anymore.
Many debtors continue to make mortgage payments after filing for bankruptcy. When you file for Chapter 13 protection, if you're behind in your mortgage payments, any past due amounts are included in your repayment plan. Bankruptcy law does not allow your mortgage lender to foreclose, as long as you keep making your current payments in addition to your payments to the trustee. Chapter 7 bankruptcies are different. If you have a great deal of equity in your home, the trustee will probably force its sale so the proceeds can go to your creditors after the mortgage is satisfied. However, if you don't have enough equity to justify a sale, you can typically keep your home and keep making your mortgage payments if you want to. Your mortgage company can and usually will accept the money without foreclosing if you stay current with your payments.
When you go bankrupt, some of your creditors will probably reach out to you, asking if you want to "reaffirm" the loans you owe to them. For example, if you want to keep your auto, and if there is a loan against it, you would have to reaffirm the loan or the lender will repossess it. Credit card companies also accept reaffirmation agreements, and in return, you get to keep your card. Reaffirmation involves entering into a new contract with the creditor in which you agree to continue paying toward the balance you owe. It's an agreement by you not to include the debt in the bankruptcy. The court must approve all reaffirmation agreements--you can't enter into one without a judge's permission.
When you file for bankruptcy, either Chapter 7 or Chapter 13, you're legally obligated to list every one of your creditors and anyone you owe money to, even if it's a personal loan owed to a family member or friend. It's illegal to keep paying them while you're in bankruptcy. You can't give them a little extra over and above your monthly payments to your Chapter 13 trustee, and you can't keep paying them while your other creditors are having their debts erased through Chapter 7 proceedings. However, after you've gone bankrupt and after your case is closed and the court has discharged your debts, the law doesn't stop you from paying those loans back at that time.