Cattle generally just stay away from an electric fence once they learn what happens if you get too close.
A water tank or other object that has a voltage gradient surrounding it, they start to sense that voltage as they approach, don't like that and generally will just stay away. If you are trying to herd them into an area where they must cross such a voltage gradient they will put up some fight or will run when finally crossing that gradient.
A good cattleman will know they are disturbed by something by the way they are acting.
Say it is a faulted water tank heater - there may be voltage gradient in the surface as you approach - cattle feel this and just stay away. Pigs however are more curious about things, they will likely come all the way to the water tank and be electrocuted when they touch it. Then the next one will be curious and approach and get electrocuted as well.
Same with electric fence - cattle learn to just stay away, pigs have to come back and test it every so often just because of curiosity.