As part of the purchase, you are given the deed restrictions and you contractually agree in the closing process to follow them. We once backed out of a purchase when we read the overly strict restrictions.
You also contractually agree that the association has the ability to fine you for violations and put a lien on your property if you don't pay. There are plusses and minuses. The minuses are obvious - PITA, picky busybodies, limited paint colors, landscaping restrictions, etc. The plusses are that in general, the whole neighborhood is typically better maintained - paint, lawn, general upkeep, etc. which affects your property value.