The HOA is created by covenant (promise) made by a previous owner, sometimes many people back from your purchase, that the property would be subject to the declaration created by that owner. The declaration creates the HOA and normally has the power to foreclose if assessments are not paid in a timely fashion.
The declaration usually contains language that puts those liens subordinate to your purchase-money mortgage, but not all the time. This is because the banks don't like to be less than the "first" mortgage.
Mortgage means pledge. You pledge to pay back the money you borrowed to buy the house. Behind only government liens, the first mortgage lienholder can foreclose for non-payment or other breach and that action will wipe out all subordinate liens. Any superior liens will remain intact and 'run with the land' meaning they still are attached.
The importance of subordination is that if the HOA forecloses, but they are subordinate to your mortgage, then the mortgage company can foreclose on them if they fail to pay your mortgage (or someone fails to pay). It the same situation as taxes on the property. They must be paid or the government can foreclose, even if the lien for the taxes were filed after the mortgage lien.
Normally, the sale is not a trustee sale, but the effect is similar. You lose title to the property, but it is encumbered by the existing mortgages and taxes liens, if any. You should consult an attorney about your rights and obligations.