A townhouse is a style of construction, whereas condominium and co-op are types of ownership. A townhouse is basically a building or unit that shares a common wall with the building or unit next door. The walls are usually straight and entry is usually from the ground floor. Townhouses usually have two or more stories. A townhouse can be a style of condominium. 

A condo is where you own the actual structure of the building jointly with the other members of the association, along with common areas such as swimming pools, tennis courts or other common areas. Individually, you own the airspace and interior of the structure, but not the building itself. You and the other members of the association own the structure together. 

A co-op is where you own shares of a corporation or organization that owns the larger structure, and ownership of those shares gives you the right to occupy a specific unit or apartment.