Why can hydrogen peroxide act as both an oxidising agent and a reducing agent?

Hydrogen peroxide has the ability to gain or lose electrons, as its oxygen atoms are in the -1 oxidation state. By gaining electrons they can go to the -2 oxidation state, and by losing electrons they can go to the zero oxidation state (the element)

When someting acts as an oxidising agent is gains electrons (removing them from the oxidised species). This can be shown by the relevant half-equations:

H2O2 + 2e –> 2OH

or in the presence of acid:

H2O2 + 2H+ + 2e –> 2H2O