Why is the mass of 1 mole of an atom/molecule equal to its gram atomic/molecular mass?(proof)
$\def\p{\mathrm{p^+}}\def\n{\mathrm{n}}$
Mass of one proton = $m_\p$ and mass of one neutron = $m_\n$. (Masses are in unified atomic mass unit-$\mathrm{u}$)

C-12 isotope consists of 6 $\p$ and 6 $\n$. Therefore, mass of C-12 isotope is equal to 6 $m_\p$ + 6 $m_\n$. Since $m_\p$≈ $m_\n$, the mass of C-12 can be replaced by 12 $m_\p$. (electrons are not taken into account since they have negligible mass)

1 $\mathrm{u}$ is defined as 1/12 of the atomic mass of C-12 isotope.

⟹1 $\mathrm{u}$ = 1/12 × (6 $m_\p$ + 6 $m_\n$)

⟹ 1 $\mathrm{u}$ ≈  1/12 ×12 $m_\p$

⟹ 1 $\mathrm{u}$ ≈  1 $m_\p$   ...equation(1)

Now,

12 g of C-12 has $\pu{N_A}$ particles and constitutes 1 mole of it. (according to the definition of 1 mole)

⟹ 1 mole of (6 $\p$ + 6 $\n$) have a mass of 12 g.

⟹ 1 mole of (12 $\p$) have a mass of 12 g.

⟹ 1 mole of $\p$ have a mass of 1 g

⟹ 1 mole of $\p$ × 1 $m_\p$ = 1 g

⟹ 1 mole of $\p$ × 1 $\mathrm{u}$ = 1 g

⟹ 1 mole of $n$ $\p$ × 1 $\mathrm{u}$ = $n$ g

Therefore, mass of 1 mole of $n$ $\p$ is equal to $n$ g

Now, the final part,

Let an atom have $x$ $\p$  and $y$ $\n$ . The atom can be considered to be $(x+y)$ $\p$  for our purposes.

1 mole of $(x+y)$ $\p$ have a mass of $(x+y)$ g.

Thus the mass of 1 mole of atoms of an element is equal to its gram atomic mass.

Molecular mass of an element or a compound is equal to the sum of the atomic masses of each type of it's constituent atoms.
Thus the mass of 1 mole of molecules of an element or a compound is equal to the gram molecular mass.