If one does not want to be in a homeowners association or can’t afford it, the easiest option is to not join one; however, depending on the rules associated with a neighborhood, joining may be compulsory.
When looking at a home, if the neighborhood has rules, one should ask for a copy of the covenants, conditions and restrictions (CC&Rs). If these covenants say one must join the association, there isn't a choice, assuming that is the house to be purchased. Whether one opts out or not depends on the rules, sometimes it is an option to opt out of certain services and save money on dues.
If one feels they are in compliance and being unfairly singled out by an association, get an attorney involved to do anything from file a formal written complaint to pursue legal action if necessary. The same goes any provision of the rules isn’t legally enforceable or that the association isn’t holding up its end of the bargain.
NOTE: Unfortunately HOA Fees are a result of living in a planned community which often looks like an apartment complex with no individual owning their own sect of land. Since one does not often own the land but only the portion of the building itself (the unit), the HOA Fees are virtually mandatory. If one has their own plot of land AND brings the title forward in fee simple, there is NOTHING a Home Owner's Association can do regarding a CC&R violation and will lack the ability to "enforce" the penalties.