A harbour is a sheltered place where ships or boats can be protected from storms. An older word for harbour is haven, hence the term 'safe-haven'. Most natural harbours are protected by headlands.
In the past, people looked for coves and sheltered bays or river mouths to be natural harbours. But as these are limited, in more modern times harbours have been made by building breakwaters, sea walls, and jetties out from the coast. Natural harbours have the advantage of staying free from silt because of the scouring effects of natural sea currents. But artificial harbours often silt up and need constant dredging.
A port is not a harbour. Ports are places for loading and unloading goods. Ports are the loading areas inside harbours.