Dissimilar metals and alloys have different electrode potentials, and when two or more come into contact in an electrolyte, one metal (that is more reactive) acts as anode and the other (that is less reactive) as cathode. The electropotential difference between the reactions at the two electrodes is the driving force for an accelerated attack on the anode metal, which dissolves into the electrolyte. This leads to the metal at the anode corroding more quickly than it otherwise would and corrosion at the cathode being inhibited. The presence of an electrolyte and an electrical conducting path between the metals is essential for galvanic corrosion to occur. The electrolyte provides a means for ion migration whereby ions move to prevent charge build-up that would otherwise stop the reaction. If the electrolyte contains only metal ions that are not easily reduced (such as Na, Ca, K, Mg, or Zn), the cathode reaction is the reduction of dissolved H to H or O to OH.
In some cases, this type of reaction is intentionally encouraged. For example, low-cost household batteries typically contain carbon-zinc cells. As part of a closed circuit (the electron pathway), the zinc within the cell will corrode preferentially (the ion pathway) as an essential part of the battery producing  electricity. Another example is the cathodic protection of buried or submerged structures as well as hot water storage tanks. In this case, sacrificial anodes work as part of a galvanic couple, promoting corrosion of the anode, while protecting the cathode metal.
In other cases, such as mixed metals in piping (for example, copper, cast iron and other cast metals), galvanic corrosion will contribute to accelerated corrosion of parts of the system. Corrosion inhibitors such as sodium nitrite or sodium molybdate can be injected into these systems to reduce the galvanic potential. However, the application of these corrosion inhibitors must be monitored closely. If the application of corrosion inhibitors increases the conductivity of the water within the system, the galvanic corrosion potential can be greatly increased.
Acidity or alkalinity (pH) is also a major consideration with regard to closed loop bimetallic circulating systems.  Should the pH and corrosion inhibition doses be incorrect, galvanic corrosion will be accelerated.  In most HVAC systems, the use of sacrificial anodes and cathodes is not an option, as they would need to be applied within the plumbing of the system and, over time, would corrode and release particles that could cause potential mechanical damage to circulating pumps, heat exchangers, etc.