The gain is a comparison to a Isotropic Radiator (theoretical radiation pattern that has equal signal in all directions) that is created by the way the antenna compresses the radiation pattern. Things like half wave, quarter wave etc refer to the antennas length/construction which basically sets how they create their respective gains.
https://www.air-stream.org/technical...ted-power-eirp
If you think of the radiation pattern as a donut of a certain volume - the more you squash the donut, the further it will move out from the centre. This is essentially the effect of increasing an antennas gain - more out with less up and down.