In order to attack towns you need to open the "Attack Mode" menu for the respective convoy you want to attack a town with. Check the nation's flag that your target town belongs to, then order your convoy to sail into the town. Once your convoy sails into the town, it's won't dock like usually, but instead attack the town. You'll be asked if you want to attack by land or by sea. If attacking by sea, you'll have to destroy all of the harbor cannons using your warships. If you decide to attack by land, the computer will autocalc the result of the battle, according to the number of soldiers in the town on one hand and the number of sailors in your convoy, as well as the hand weapons available (cutlasses and muskets) on the other hand.
So if you have an overwhelming number of sailors and sufficient cutlasses and muskets for them, clearly outnumbering the soldiers in the target town, you should attack by land and save a lot of time. Attacking by sea is much cheaper in terms of the necessary manpower and expensive weapons (you only consume cannonballs, heavy shot) but it can take a lot of time, especially if the wind conditions are unfavorable.
Either way, before attacking a town by land or by sea, you'll have to destroy any military vessels protecting the harbor.
Hope that helps.