Please elaborate on how they keep "undesirable" people out - a statement like this has no meaning without any evidence. The HOA is not involved in the purchase of a house in any way.
Most HOAs have enough legalese baked into them that they can even hold eviction over tenants heads. It's absolutely a class weapon that gets used as a bludgeon. And if they can't technically evict you, they sure can make your life hell until you leave. Selective enforcement is the name of the game with these types.
American Dad covered this - Roger decided to get back at Stan so corrupted the HOA and did all sorts of things like arranging trash pickup, installing a hydrant on his lawn, etc.
If the HOA don’t like you, it seems there little recourse.
And they absolutely will. After I moved out of my last HOA, I found out the towing company had a flat rate kickback to the HOA organization for every tow they made. Genuinely baffles me how it's even legal.
The HOA can not restrict purchase sure, but can specifically target PoC for "violations" while ignoring the white households who are committing violations. This has the effect of working to force these folks out and maintaining the racial status quo of the HOA.
In the 70s (I think) and before, HOA were definitely active gatekeepers though against PoC, and then after that with new laws passed, moved to these more "subtle" methods.