in a magnet, who is it that like poles repel and unlike poles attract???
This is because the magnets produce something called magnetic field. When you put two magnets close to each other, their magnetic field interact and causes them to exert a force on each other.