The crystal structure of barium fluoride BaF₂ and magnesium fluoride MgF₂ is cubic and tetragonal lattice respectively.
There are difference between the cubic and tetragonal lattice of any crystal. For cubic lattice a = b = c and α = β = γ = 90⁰ and for tetragonal lattice a = b ≠ c and α = β = γ = 90⁰ (where a, b and c are the edge length of the lattice and α, β, γ angle of the crystal lattice).
The difference of the structure depends on the size of the ions present in the compound. In BaF₂, the ions are Ba²⁺ and F⁻. In MgF₂, the ions are Mg²⁺ and F⁻.
Although the size of the anion in both the crystal is same, there is a huge difference between the size of the cation, which affect the crystal lattice of the compound.