Atomic number is the number of protons found in the nucleus of an atom. A single atom of O ie oxygen has 8 protons and has an atomic number of 8.
Here, O2 is oxygen gas. It is a diatomic molecule ie a molecule containing two atoms of oxygen.
O3 is ozone. It is a triatomic molecule containing three atoms of oxygen.
We must understand that both O2 and O3 are molecules made of atoms of oxygen(O). They do not have atomic numbers assigned to them. Atomic numbers are assigned for atoms, and not molecules.