Whenever different metals are placed in a conductive liquid you create a battery. If you connect these pieces of metal together, current will flow. The current will be removing metal from one of the metal pieces = "electrolysis". If this piece is the zinc in your flashlight battery that is good, but if one of the pieces is your propeller it is bad.
The zincs you use on a boat are called "Sacrificial Anodes". Zinc is used because it has a higher voltage in the water so the current will be more inclined to flow from it than from your propeller. To complete the electrical circuit, the zincs must be connected to the items they are intended to protect. Usually this is no problem because the zinc is bolted right to the shaft or underwater housing. Non metal boats will usually have a copper bonding wire inside that connects all the underwater metal items together so they all share the protection from zinc anodes. Since engines use the metal frame as the negative battery connection and the engine is connected to the prop shaft, the engine and the negative side of your 12 volt system are also part of this bonding connection. This bonding wire is usually connected somewhere to the rigging. This is not for electrolysis protection but for some protection from lightning strikes to conduct it into the water through the items connected together.
If other currents are allowed to get into this bonding circuit they can easily overpower the small voltage available from your zincs and defeat the protection you need. This is usually the most destructive form of electrolysis and you notice it because your zincs get eaten up very quickly trying to keep up. Under normal circumstances, zincs should last at least a year if they are working normally, and much longer if you don't have any problems. If they are being "sacrificed" in a shorter period you need to find where the external current is getting in.
The most common source of this external current is the shore power connection, especially the ground lead. Docks are notorious for bad wiring and often the ground lead is not connected to ground, is connected to the neutral, is being used for carrying current to a mis-wired boat, and all other sorts of problems. So the ground lead should never be directly connected to the ground bonding system we talked about earlier. The purpose of the shore power ground lead is to provide a return path for current if there is a short circuit or power leakage from an appliance or the wiring on the boat. You don't want it to connect all the underwater items on your boat to the underwater items on all the other boats and the dock because now your zinc is trying to protect everyone else too.
Unfortunately it is not always possible to keep the circuits separate due to interconnections such as shore power chargers. There are a number of ways to separate the shore power ground from the boat's underwater bonding system. The preferable and safest way is to use a galvanic isolator to introduce a 1.2 volt insulator in the circuit. This is enough to isolate most galvanic voltages but it will still conduct electrical faults and keep the boat safe in the event of a ground fault in the wiring or in an appliance. The galvanic isolator must be rated for the size of your shore power circuit.