Electrolysis is a very good point. That is part of the reason that heaters have a sacrificial rod. Someone mentioned "not replaceable." Many that I've seen WERE replaceable.
You MUST properly install the tank. The usual think, if the common copper flex connectors are used, is that they have ELECTRICALLY INSULATED connectors, called "dielectric fittings." These are on water tanks and your gas meter if you have nat. gas. The two pipes, hot and cold, should be bonded together and grounded. The tank should be grounded through electrical. Interestingly, the gas connection to the heater (obviously if gas or LP) IS NOT a dielectric connection at any of the gas appliances. This means the furnace, dryer, range, or any other gas/ LP appliances are all interconnected by the grounding conductor (green or bare) of the electrical system, as well as interconnected by the house gas piping, if metallic. And that includes the water heater.
When we installed gas/ LP "back then," the gas piping had to be bonded by grounding wire to the water piping and to the electrical system ground or to a ground stake. Common 8' ground stake. So even though a water tank uses dielectric fittings at the water connection, the gas piping, if used is bonded/ grounded, AND the water tank shell is grounded / boned if it is electric. Go figure??
I have never really understood the actual electrics of electrolysis in that situation.