There are many ways to structure coast guards. They may be military or civilian; part of the defense establishment or in a separate department; multi-mission or single purpose.
Here is a story of how the Philippine Coast Guard separated from its parent organization, the Philippine Navy. The narrative may be a bit self serving as it was posted by Fidel Ramos, who was President of the Philippines at the time, and who refers to himself in the third person, as FVR in the narrative.