We perform a first-principles study of Mg adatom and adislands on the Mg(0001) surface, and Be adatom on Be(0001), to obtain further insights into the previously reported energetic preference of the fcc faulty stacking of Mg monomers on Mg(0001). We first provide a viewpoint on how Friedel oscillations influence ionic relaxation on these surfaces. Our three-dimensional charge-density analysis demonstrates that Friedel oscillations have maxima which are more spatially localized than what one-dimensional average density or two-dimensional cross sectional plots could possibly inform: The well-known charge-density enhancement around the topmost surface layer of Mg(0001) is strongly localized at its fcc hollow sites. The charge accumulation at this site explains the energetically preferred stacking fault of the Mg monomer, dimer and trimer. Yet, larger islands prefer the normal hcp stacking. Surprisingly, the mechanism by which the fcc site becomes energetically more favorable is not that of enhancing the surface-adatom bonds but rather those between surface atoms. To confirm our conclusions, we analyze the stacking of Be adatom on Be(0001) - a surface also largely influenced by Friedel oscillations. We find, in fact, a much stronger effect: The charge enhancement at the fcc site is even larger and, consequently, the stacking-fault energy favoring the fcc site is quite large, 44 meV.