They don't work because there is not one
magnetic field on Mars, rather there are dozens. These small fields are powerful, concentrated in the crust, and scattered over the surface of the planet. In their absence, compass needles would lie still; in their presence, they spin, pointing first at one bar magnet, then another. How well these crustal fields protect the planet is a mystery, and one that may be solved soon by the MAVEN satellite, which is on its way to Mars right now.
What we do know is that if a compass ever worked well on Mars, it was over 3.5 billion years ago. Before that time, Mars had a molten core, whose contents constantly churned upward towards the surface. This process of convection permitted cooling of the interior, as well as active volcanism in the highlands and plains. Volcanoes brought iron to the surface, giving Mars its signature color. Iron in the core also moved electrons, which created a planetary dynamo: a device that converts mechanical energy into electric energy. Electric fields generate magnetic fields. Large magnetic fields can provide protection from
solar wind for any planet as long its interior maintains a steadfast supply of molten metal.
Large magnetic fields also decay unless maintained. After the first billion years or so, the Martian interior cooled to the point where convection halted. When the iron ceased to flow, the dynamo died. Volcanism declined. The last iron deposits from the interior left their marks as pockets of magnetism, called crustal anomalies, largely sequestered in the southern hemisphere.