Because they have similar amounts of valence electrons.
To understand why bonds between different atoms are similar, it is necessary to look at the amount of electrons in the valence shell of each atom involved.
In the case of the question, there is the bond MgO and BaCl2, in which it can be seen that Mg and Ba belong to the same family, thus having the same amount of electrons in the valence shell (2 electrons).
Furthermore, O and Cl are elements of close families (family 6 and family 7), so they have, respectively, 6 and 7 electrons in the valence shell.
So, the bonding in magnesium oxide, MgO, is similar to the bonding in barium chloride, BaCl2 because they have similar amounts of valence electrons.
Learn more about valence electrons in: brainly.com/question/22637914