A Coast Guard is an organization that protects people at sea. The role of a coastguard varies greatly by country. The coast guard is sometimes part of a military, or a semi-military organization, or else is a law enforcement (policing) agency. However, the coast guard is always separate from the Navy.
For example, the United States Coast Guard (USCG) is a branch of the military. Their duties include searching for people, ships and boats in danger at sea, rescuing those in danger and law enforcement to protect people from terrorism and crimes at sea. It can also become part of the Navy in a time of war.
By contrast, Her Majesty's Coastguard in the United Kingdom is neither a military force nor a law enforcement agency. Its only job is to lead searches and rescues for those in danger at sea, while the Royal National Lifeboat Institution launch most of the rescue boats.