How to prevent galvanic corrosion on water tank inlet
You need to use dielectric unions between the copper pipes and steel water heater.  They prevent electric current from flowing through the metal, which prevents galvanic corrosion.