Why does metal corrode?
Metals are extracted from ores. In the process of extraction, it must be given a certain amount of energy to make it in a high energy state. The basic law of materials always tends to be in a low energy state, so metals are thermodynamically unstable and tend to react with the surrounding environment (such as oxygen and water) in order to achieve a lower and more stable energy state, such as life.
Formation of oxides. Take iron as an example:
Cathode: O_2+4e+2H_2_4OH-Fe2 +2OH-Fe(OH)2 Fe(OH)2+1/2O2+H_2_2Fe(OH)3_