Here's why:
* Protons have a positive charge and a mass of approximately 1 atomic mass unit (amu).
* Neutrons have no charge and a mass of approximately 1 amu.
* Electrons have a negative charge and a mass that is much smaller than that of protons or neutrons (approximately 1/1836 amu).
Since the mass of electrons is negligible compared to protons and neutrons, the atomic mass is essentially determined by the number of protons and neutrons in an atom.