They both have the same chemistry but they form different ways. Gabbro forms inside the earth from slowly cooling magma, and as such it has bigger crystals (grain size). It is what is called intrusive/plutonic, which means it formed under the earth's surface. Basalt is the same thing but is called extrusive or volcanic, which means it came to the surface of the earth through a volcano or oceanic ridge. Basalt cools much quicker so it's crystals have less time to form so it has a smaller grain size.