You should retain counsel immediately to help you clear the title to your property. While you may not be personally liable to prior lien holders, your property may yet be subject to liens. A real estate attorney will review the property's title, identify the liens on the property and any other defects in the title, and help you form a plan for getting clear title to the property.
Disclaimer: Please note that this answer does not constitute legal advice and should not be relied on because each state has different laws, each situation is fact specific, and it is impossible to evaluate any legal problem without a comprehensive review of all the facts and documents at issue. This answer does not create an attorney-client relationship.
While I agree with the prior answer that you should retain an attorney to assist you, I do not agree that clearing title is the likely outcome. Without knowing all the details it is impossible to say anything definitive. Any mortgage holder or lien holder who has a bona fide lien can foreclose. If the sale at which you bought was of a lien which was inferior to the lien now being foreclosed, proper completion of that lien will extinguish your claim unless you either buy that mortgage or find a way to successfully defend the foreclosure action. Normally, homeowners associations, condominum associations and judgment creditors are inferior liens if there is a mortgage on the property, and may even be inferior to other inferior liens.
A certificate of title normally issues 10 days after the sale, assuming you paid the bid amount as required by law. This conveys the property to you, but SUBJECT TO any superior liens of record, and if by any chance the foreclosure was not done right, it could even have failed to dispose of inferior liens.
Depending on the numbers, there are times when it makes economic sense for someone to bid on a foreclosure of a junior lien, because there are times when the property is still worth more than the total due on all superior liens plus the bid amount. However, this is a classic example of caveat emptor, let the buyer beware.
If somehow the property is worth more than what is owed on the foreclosing mortgage and if there are no other superior liens, you can try to sell or refinance the property and then pay off the total due on the first mortgage. If you think this is a possibility, get that in the works immediately and then try to play for time with the first mortgage foreclosure. They may even agree to give you some time to consummate a sale.
However, if all it is worth is less than the total due on the first mortgage, unless you can rent the property until the first mortgage foreclosure is final and a sale held, you are likely out what you paid. If you can rent it, even at a discount, between now and then, that is probably your only chance of recouping anything. If you do that, you should be honest with potential tenants, and discount the rent so that you don't wind up with a tenant looking to sue you.
Buying properties at foreclosure auctions is difficult and potentially dangerous.