Why do all atoms of an element have the same atomic number?
Because atoms of an element has, essentially, the same number of protons.
For ground state (no charge) atoms, you have to remember the following facts:
For ions (which may either have a positive or negative charge), only the number of electrons are being changed. If the ion is negative it means that an electron has been added to the configuration. If the ion is positive, it means that an electron is removed from the configuration.
For isotopes (elements that have different masses, no charge), only the number of neutrons has been changed. Examples are Carbon-12, Carbon-13, and Carbon-14.
Carbon-12 : 6 protons +
Carbon-13 : 6 protons +
Carbon-14 : 6 protons +
Because none of these situations change the number of protons, the atomic number stays the same regardless.