Short answer: You can't.
Ships in EU4 are not able to attack provinces, neither are they able to attack enemy ships that lie in the harbor of a city/province.
What you can do is blockade the harbor of the enemy city, so that other ships cannot enter or leave. This greatly improves your chances for a shorter siege by land troops on this coastal province.
The rationale behind this is that if your troops are besieging a city on the coast, the defenders could get support (food, water, supplies) through incoming ships. So a coastal province automatically gets a bonus on defense if you do not block the harbor with your ships. You can see this bonus on the siege screen. (Screenshot will follow.)
A coastal province automatically gets blockaded if you have ships in the adjacent water region where the city's harbor lies. (given that you are at war with the province owner)
So it is always a good idea to blockade the harbors of enemies provinces you want to conquer.
Also it should be noted that blockading provinces gives you additional warscore.
The Detach Blockade button will split a troop from your ship squad that is large enough to blockade a harbor. It works pretty much equal to the Detach Siege button of land troops.