Electric fence drivers often use ordinary car ignition coils to generate the high voltage. Now when I was little I had a gadget with a 6V battery, momentary-contact switch, condenser, 6V car ignition coil and spark plug all made up on a piece of board. I used to persuade unsuspecting friends to touch the (exposed) HT terminal while I pressed the button. Amazingly they were still friends afterwards.
An electric fence has a timer that makes it put out the same kind of output once every few seconds. If you're a healthy kid then yes it is just a nasty thump. If you're older and less healthy it makes you feel a bit funny for half a minute. If you have a heart condition then it might be bloody lethal, and if you haven't been diagnosed you probably don't know about the risk.
Note that the same ignition coil in a car with the engine running will produce an output which is bloody lethal to anyone, because instead of one isolated thump you get them at a rate of hundreds or thousands a second and even if your interference does stop the engine it doesn't stop quickly enough.
Anyway, I do remember there being at least one electric fence on railway property (I don't think it's still there though) - along the back of the platform at Bescot station. Concrete posts with holes in them and galvanised steel wire threaded through the holes from one end to the other. The posts acted as tolerably good insulators even when it was raining, so what you had was a kind of near-field antenna coupled to the overhead. If you brushed against it you could certainly get enough of a tingle to make you jump.
As someone who has a heart condition, whose parents were born on a farm and walks in the countryside I can confirm that you're not going to die from touching an electric fence!
Even if you have a pacemaker, the "shock" of touching the fence won't affect it.
No farmer wants to harm their livestock, having a lethal fence would be a very stupid thing to do! Animals have heart attacks too.
Electric fences are perfectly safe. Whilst I wouldn't say go out there and hold on to one, I've slipped before now and instinctively grabbed one and you certainly know it's electrified, but you're in no danger at all.
Touching the overhead wires (or anything connected to them) or the third rail would kill you. Heart condition or not. So an electric fence next to railways is a lot safer than the overhead wires on the railway.
So, the answer to the OP is, whilst we have electrified railways, electric fences pose no issue at all.