GM4 is synthesized by the sialylation of galactosylceramide (GalCer), while the ganglioside GM3 is synthesized by the sialylation of lactosylceramide (LacCer).