Compass magnets align themselves with Earth's magnetic field due to their own magnetic properties. Electromagnets, like the one found in devices such as phones or microwaves, can create magnetic fields that may interfere with a compass's accuracy if they are strong enough and placed close to the compass.