The electric third rail is a rail running parallel to the first two rails on electric train systems such as BART. The first two rails are as you're familiar with on any train: it carries the weight of the train. The third rail carries 1000-volt DC electricity (in the case of BART, anyway; other systems may be different). Small paddles extending from the side of car contact the third rail, driving electric motors, providing power to the train.

Pissing on the third rail is a bad way to die, or so I'd imagine.

It's sort of a modern version of "Why don't you take a long walk off a short pier?" or "make like a tree and get outta here," and serves well for "piss off!" as "ah, go piss on the third rail!" especially while waiting on the platform for the next train to arrive.