Call

$Z$, $"the atomic number"$ of magnesium is 12. This means that there are 12 positively charged nuclear particles. This defines the particle as a magnesium atom.

To represent the $""^24Mg$ isotope, we thus need 6 more neutrons.