Corrosion is slow decrease of any element or matter in environment by some chemical reaction. e.g. oxidation, rusting etc.
In galvanic corrosion, which is an electrochemical reaction, some metal act as anode and some metal as cathode. The following reaction occur at electrodes
At anode: Fe → 2e‑ + Fe2+
4Fe2+ + O2 → 4Fe3+ + 2O2-
At cathode: ½ O2 + H2O + 2e- → 2(OH)-
Fe2+ + 2(OH)- → Fe(OH)2
Fe(OH)2 ⇌ FeO+  H2O
Fe3+ + 3 OH- ⇌ Fe(OH)3
Fe(OH)3 ⇌ FeO(OH) +  H2O
2 FeO(OH) ⇌ Fe2O3 +  H2O
Corrosion may occur by microbial attack, by action of high temperature (non galvanic).
Coating by zinc is better to protect metal from corrosion. This is because, on coating the metal by zinc, it acts as physical barrier and protects the metal from environment. If the coating is removed, then zinc and metal form a cell, where zinc acts ac sacrificial anode, and zinc corrodes and deposit on iron. Thus it further protects form corrosion. Outer portion of zinc coating reacts with oxygen, moister and carbon dioxide to form zinc carbonate. This zinc carbonate adheres to inner zinc very strongly and protects the inner metal from corrosion.