Sangeetha Pulapaka

I think you meant to ask why like poles in a magnet attract and why do they repel?

I have to explain a little bit of chemistry here

.Everything is made of atoms—every star, every tree, every animal. Even people are made of atoms. The air and water are, too. Atoms are the building blocks of the universe. They are very, very tiny particles. Millions of atoms would fit on the head of a pin.

When an atom is in balance, it has the same number of protons and electrons. It can have a different number of neutrons. Electrons stay in their shells because a special force holds them there. Protons and electrons are attracted to each other. Protons have a positive charge (+) and electrons have a negative charge (–). Opposite charges attract each other. 


In most objects, all the atoms are in balance. Half of the electrons spin in one direction; half spin in the other direction. They are spaced randomly in the object. Magnets are different. In magnets, the atoms are arranged so that the electrons are not in balance. The electrons don’t spin in a balanced way. Instead, the electrons line up. This creates a force of energy called a magnetic field around a magnet. 

We call one end of the magnet the north (N) pole and the other end the south (S) pole. The force of the magnetic field flows from the north pole to the south pole.Magnets repel or attract because of the number of electons in it. If one end of the magnet has more electrons and one end of the magnet has more protons, then they attract each other, because the electrons get attracted to the protons.