Protons and electrons.
Atomic number is the same number as the number of protons in an atom's nucleus. and is also the number of electrons.
The atomic number is the same as the number of protons in an element. It is sometimes also the same as the number of electrons depending on the charge of the element.
How? Presumably you mean why? Because that is the convention.
The atomic number is the number of protons and the number of electrons.