Magnets work due to the alignment of the atoms within the material. The atoms in a magnet are aligned in the same direction, creating a magnetic field. This magnetic field exerts a force on other materials with unaligned atoms, causing them to be attracted or repelled based on the orientation of their atoms. This phenomenon is what allows magnets to attract or repel other materials.