During the corrosion of iron, the cathode reaction and the anode reaction always happen together. Therefore, if either reaction does not take place, the iron will not corrode.
1/2O2 + H2O + 2e- 2OH- ( Cathode Reaction )
Fe
Fe2+ + 2e- ( Anode Reaction )
Fe + H2O + 1/2O2 Fe(OH)2
( Reaction formula of iron corrosion )
Elimination of dissolved oxygen will suppress the cathode reaction and iron corrosion will not occur.
Corrosion of copper, used in pipes for hot water supply, follows a reaction formula similar to the described above. If dissolved oxygen is suppressed, it is also possible to prevent corrosion of copper.
*You may think that dissolved oxygen comes from bubbles formed as the water is boiled, but this is the oxygen from the vapor that dissolves into water.