When you buy the house you agree to abide by the HOA rules.
Don’t like it, don’t buy the house.
At least with the HOA, you get the rule book and sign a paper stating you agree with it.
When you buy a house in an non HOA, you don’t sign a single piece of paper stating you will comply with their rules/laws, and you certainly don’t get the 5,000 page code book either. And the rules/laws can change on whims and sometimes be enforced retroactively.
HOAs are at least up front about it.