Group 2 elements, also known as alkaline earth metals, have two valence electrons in their outermost electron shell. Because of this, they typically tend to lose these two electrons to achieve a stable electron configuration, usually resembling the nearest noble gas.
As a result, Group 2 elements most commonly form ionic bonds. In an ionic bond, one atom (in this case, the Group 2 metal) donates its valence electrons to another atom (typically a nonmetal), resulting in the formation of positively charged cations from the metal and negatively charged anions from the nonmetal. The electrostatic attraction between these oppositely charged ions leads to the formation of ionic compounds.
Overall, the tendency to lose two valence electrons and form cations, combined with the attraction to nonmetals that can accept these electrons, leads Group 2 elements to predominantly form ionic bonds.