How does Ethernet magnetics work?
There are a few bad things that the system was designed to mitigate, one is ESD, noise and ground loops.

The first transformer (up down one) is an isolation transformer, it passes the high frequency signals that represent the bits of ethernet, but rejects DC.

The second transformer is a common mode choke, it blocks signals that are common to both terminals and allows signals that are not common from both terminals to pass through (like the current from the first isolation transformer, which ethernet signals will only generate current in one direction or reversed, but not common to both terminals)



The first transformer blocks DC and most static generated fields (from moving cables across the floor or people) , this means that DC currents are blocked and if you connect an ethernet to to different devices, they might be at different potentials but DC current will not pass between them. 

If high voltages or noise do couple into the cable they will do so mostly on both wires, and couple through the first transformer via capacitance. These will be blocked by the second common mode transformer, and returned back to the source (electromagnetic signals follow the path of least impedance (meaning resistance and inductance)) through the devices chassis which most often is connected to ground.