Homeowners Associations (HOAs) are entirely voluntary communities of private homeowners who create their own rules that apply to all property owners.
Because they are voluntarily agreed upon, these rules can satisfy the preferences of those who voluntarily live in the community. Homeowners are free to consent to whatever rules they prefer, provided those rules do not impose force on anyone who is not a voluntary member of the HOA.
For example, property owners may voluntarily agree in advance to ban certain activities, or set specific requirements for living in the community. Generally speaking, homeowners in a community are free to agree in advance to virtually any rules they choose within the limits of applicable law.
HOAs allow people who have a strong preference for a particular lifestyle to create a community that serves their interests — a form of ground-up governance through private law and contract.