This is all well and good for a boat isolated from the dock and stored on a mooring. To help mitigate damage from this natural electrochemical reaction, a typical boat will have sacrificial anodes installed to corrode rather than the metal in the galvanic cell. In this cell there will be winners and losers in the form of unwanted metal corrosion of the less noble metal in the cell, which is unfortunately often expensive underwater metals such as aluminum outdrives. This creates a natural phenomenon known as the galvanic cell.
The issue for boats plugged into shore power is that each one is electrically connected to every other one in the marina via the system's grounding conductor – the green wire.