A shipyard is a city upgrade which gives a bonus colonist (if first one) and allows the construction of large numbers of ships. Shipyards are represented on the main map by a slightly larger, gold-colored version of the standard port icons (an anchor if vacant, a ship's wheel if not vacant or actively constructing ships).
Shipyards can be constructed in any port city with a base tax value of 6 or more; however, since ship construction caps are affected by tax value, shipyards are most effective in the wealthiest provinces. Shipyards cost 1000d plus 100d for every shipyard that's already built. It takes 36 months to complete a shipyard.
Any port can shelter any number of ships, so a shipyard is never necessary. However, having one does make it possible to construct a large fleet in a short time, as the host city's shipbuilding capacity is multiplied by 10.
Owning at least one shipyard gives a country a bonus of 1 extra colonist per year (beyond other factors). There is no advantage to having 2 or more shipyards in terms of free colonists. Therefore, if you are building a shipyard to get the bonus colonist, you should only build one.
Many major powers and a few other countries can receive a shipyard by a scripted event at some point. Countries which can get a shipyard via event include Portugal, Spain, England, the Ottoman Empire, the Netherlands, and Venice. In most cases, the choice that gets the shipyard is the historic event option that the AI countries will choose. Two great powers that do not get a shipyard via event are France and Russia, both of which should build a shipyard as soon as possible if pursuing a colonial strategy.