Chad,
The sacrificial anode is used to control an electrochemical reaction, but not the separate chemical reaction of the caustics upon any, and all reactive metals.
An example.
You stick an aluminum boat into seawater, and the sacrificial anode will help protect the boat hull from electrolysis. The seawater is not reacting, but is an electrolyte serving in an electrolysis reaction, resulting in oxidation.
You stick that same boat in sulfuric acid or say, sodium hydroxide, and while the boat won't corrode from electrolysis, the boat AND the magnesium will still undergo rapid decomposition from the chemical reaction of the reactants alone.