In acidic and basic media, hydrogen peroxide is strong oxidizing agent.
2H2O2→2H2O+O2
It breaks chemical bonds (oxidative degradation) of the chromophores (that produce colour) in the cloth. Due to this, visible light is not absorbed and the cloth gets whitened.