Sacrificial anodes only work when suspended in an electrolyte solution, aka salt water or mineral (hard) water. My water heater doesn't even have one cause I have neutral PH water with nothing in it so it wouldn't do anything anyway. (I've had people tell me my water tastes bad, I say no that's just how pure water tastes lol). The ones on my boat don't have power to them, the difference in metal creates the charge, that's how the anodes work. I dunno about big ships but that's the basis of a battery, suspend two different metals in a electrolyte solution and a charge is created, give that solution something to run through better besides the good parts and it'll attack that and run power through that first aka the sacrificial anode.
Navy ships work different because they actually put out a charge to demagnetize the entire hull. (Philadelphia experiment) thought this was cloaking technology but it's basic anti mine technology. So who knows how sacrificial anodes work on those things.