Here's why:
* Beryllium is in group 2 of the periodic table, meaning it has a +2 charge when it forms ions.
* Fluorine is in group 17 of the periodic table, meaning it has a -1 charge when it forms ions.
To form a neutral compound, you need two fluoride ions (2 x -1 = -2) to balance the +2 charge of the beryllium ion. This gives you the formula BeF₂.