Well, it's called a "ground fault interruptor" because it protects against FAULTY grounding. The fault can be a crossed wire (excessive current in the ground wire), or loose connection (faulty ground connection), or can be something as simple as a water pipe coming into the house from the north, while the electric service and its grounding stake is located to the south. Two different potentials, but both 'ground'.
As for HOW it protects, it uses a sensor that disconnects the AC current in your wiring if and only if the hot (black) and the neutral (white) wire don't carry equal and opposite current. The excess of current would mean that a third conductor (you, or leakage to the protective ground wire) is involved, in an unintended way.