Charge of polyatomic ions doesn't equal the charge of ions it consists of?
H-O-O-H.  The bond in the middle is covalent.  Deprotonate to $\ce{{HOO}^{-}}$ (hydroperoxide) then $\ce^{^{-}{OO}^{-}}$, peroxide dianion, $\ce{O2^{2-}}$.  You learn it by doing it, having examples, learning what to look for, and gaining understanding.  Both oxygens are in the -1 oxidation state.

Even good answers here have a legitimate diversity of explanation.  The world is complicated and dirty.  Unlike physicists (quantum gravitation, SUSY, dark matter), we can test our predictions with experiments.  Chemists are not too stinking proud to admit we were wrong, e.g., benzene displacements then palladium catalysis.  That is how we make real world progress, by discovering footnotes.

Introductory inorganic does not have wiggle room.