When we consult periodic table, we see that neutral oxygen atom have eight protons and eight electrons. the ion O2- has eight protons and ten electrons.
Because the charge of ion shows that it gains two electrons, so before it was 8 electrons and after gaining 2 electrons it will be 10 electrons.
if an element gains electrons, it is negatively charged and when it loses electrons it is positively charged, proton always the same.