From what I understand, buying an HOA lien generally doesn’t give you rights over any outstanding mortgages, as the mortgage typically has priority over the lien. However, in some rare cases, if the HOA lien is super-priority and the foreclosure sale wipes out the mortgage, the mortgage might be extinguished, but this is highly dependent on state laws and specific circumstances. It's worth double-checking with a local real estate attorney or expert to confirm how it works in your area.
I don't believe this is possible, if it is, it's a well guarded secret. You can buy an HOA lien and fight off the mortgage foreclosure with various defense strategies utilizing a knoweldgeable legal team.
You should read "HOA Foreclosure Play for Big Profits at the County Auction" that Tony wrote a while back.