why is the electron affinity of alkaline earth metals, like Be, Mg, Ca,Sr, Ba, zero?
The electron affinity of an element is the energy change which accompanies the addition of an electron to an atom in the gas phase to produce a negatively charged anion.
It is usually a negative value as addition of an electron leads to release of energy. Higher the release easier it is to form an anion.
Electron affinity is usually calculated experimentally, however in some cases like in group 2 elements mentioned by you the value is calculated theoretically and hence is found to be zero or near zero.