The over-simplified way of showing this is that each oxygen atom has a negative one oxidation state, but that is not really so because the peroxides do not come in individual oxygen atoms. Peroxides are not as stable as oxides, and there are very many fewer peroxides in nature than oxides. H 2 O 2 is hydrogen peroxide. Hydrogen in compound always an oxidation state of plus one except as a hydride. A hydride is a compound of a metal and hydrogen.
Hydrides react with water, so there are no hydrides found in nature.
The formula XH or XH 2 or XH 3 or even XH 4 where X is a metal is the general chemical formula for hydride. Diatomic gases such as O 2 and H 2 are also in this category. All compounds have a net oxidation state of zero. The oxidation state of all of the atoms add up to zero. Any ion has the oxidation state that is the charge of that ion.