If we use zinc in both methods, then the same process occurs: zinc corrodes in preference to iron, and eventually zinc has to be replaced. So what's the difference?
They are used in different media. Galvanization is used to protect iron exposed to non-corroding medium (air), while sacrificial electrodes are used to protect iron in electroconductive and corrosive medium (sea water or moist soil).
Protective zinc oxide layer on galvanized surface is desired to stay undisolved, while the purpose of sacrificial electrode is to keep being oxidized to assure electron flow to other metal surface. In latter case medium electrconductivity is a must for ion transfer process, while corrosivness is needed for oxidized zinc surface layer disolution.
Galvanising is coating the iron with a layer of zinc in order to prevent it from rusting. However, sacrificial protection is attaching a piece of zinc to the iron object. Both methods use the same principle to work. Even if the iron is exposed to water or oxygen in the air, the water and oxygen react with zinc, as it is more reactive.