The average atomic mass of an element is called that way because it is calculated by taking the weighted average of the atomic masses of the element's stable isotopes.
As you know, some atoms can have the same number of protons inside the nucleus, in which case they are atoms of the same element, but different numbers of neutrons inside the nucleus
So if you want to calculate the atomic mass of an element, you need to look at the atomic masses of all the atoms that have the same number of protons in the nucleus.
Now, not all the atoms that have the same number of protons in the nucleus will have the same atomic mass because some of them are isotopes, i.e. they have different numbers of neutrons in the nucleus.
In this case, magnesium has three naturally occurring isotopes.
This means that the average atomic mass of magnesium will have to account for the fact that these isotopes have different atomic masses.
So why take the weighted average of these atomic masses?
Because the isotopes are not equally abundant, meaning that some are more abundant than others.
This implies that an isotope will have a bigger contribution to the average atomic mass of the element if it's more abundant. In other words, the more abundant an isotope is, the more it will contribute to the average atomic mass of the element.
So we use the weighted average of these atomic masses to reflect the abundances of the isotopes.