Here in Marin, CA, comparing Condos and Town Homes are like comparing oranges and apples. They are two different things.
Towh Home is a style of homes - you will often see MLS say 'Town Home style condo, no neighbors above or below). It is usually two stories, attached, with neighbors on both sides (unless it's an end unit) and no neigobors above you, nor below you. This is a big advantage to own a town home, quite, some freedom (you don't have to worry about downstairs neighbors when you walk).
A condo is a form of the ownership of a property. Like others said, you own the interior of the building but not exterior and you don't own the land the property sits on. Often times, a town home can be a condo.
Another term you will hear is PUD, Planned Unit Development - which is mostly what it says - a development that's master planned. condos as well as single family homes can be part of PUD.
HOA is Home Owner Association, often heard when discussing condos, town homes, PUDs. Single Family Homes can also be part of development with Home Owner Associations. Homeowners in PUDs often form HOAs which will have CC&Rs to govern what's acceptable or not in this development or assocation. They also determine the fees, if any, associated with the development.
For HOAs for condo development, the HOA fees often include fees assocated with external building maintenance (because the home owner only owns the internal space); and other HOAs may only require fees to cover common areas/facilities and ground keeping, etc (condo HOA fees also cover those and possibly some utilities).
Hope this does not confuse you.