Although each townhome and condo can set up their own set of rules on how they want paid the general process is that they have one HOA fee that covers all of the costs for account management, daily maintenance and upcoming maintenance. The HOA's should have a Capital Expenditure Account that is kept for when the buildings need large maintenance items such as roofs and painting. If the HOA does not have this type of savings account then they have the right to "assess" the homeowners a specific amount of money for these types of things when they are needed. Of course this has to be voted on and approved by the HOA.
There are also times when the condo / townhome is located in a larger neighborhood community with community amenities that are shared by all people that live in the community. In this case you will have a main HOA fee that is specific to the townhome / condo and then another HOA fee that is specific to the entire neighborhood.
It is very important to remember that my statement above is general and that there can always be different ways that a specific HOA handles their business. The most important thing is to research thoroughly the specific property's HOA to find out how they handle maintenance and financial issues.
Please let me know how I can be of further assistance and best of luck!