At a high level, anyone can sue you to enforce a deed term, as long as the organization/person with an interest is around to do it and knows to do it. As an easy example, a long time ago people added racist stuff to deeds, but those family descendants no longer enforce it. HOAs don’t die like people and collect dues so they don’t run out of legal fees.
You can try to get dead HOAs removed from a deed, and you can try to get a living HOA removed from a deed. Obviously one is a lot easier because it doesn’t fight back. You can also get the residents to vote to dissolve an HOA. Some HOAs expire after so long if the residents don’t renew.
TLDR you can’t buy the house without agreeing to the HOA.