The name "Great Barrier Reef" is a misnomer. The entity is really a collection of many distinct coral reefs.
How coral reefs are created
It's an intricate process, but here's a quick overview:
The thick bases of a coral reef is made from the skeleton remains of the ancestors of a miniscule marine animal called the coral polyp.
Each new coral polyp produces a protective skeletal shell around itself. It then attaches itself to neighboring coral polyp shells to form sizeable, fantastically configured colonies.
The lavish coral colors are not produced by the polyps. They are created by a photo-synthesizing algae that lives symbiotically with the coral polyps.