All magnets have two ends where the pull is strongest – a north pole and a south pole. The poles are named this way because if a magnet is floating in water or is suspended by a string tied around its middle, it will align itself in a north-south direction, consistent with the magnetic field of the Earth.
When a north pole face a south pole, they feel a force pulling the magnets together. But when the north poles face each other or the south poles face each other, they feel a force pushing them apart.
Some kinds of metals (like steel that the needles are made of) are made up of billions and billions of individual atoms that each have the properties of a microscopic magnet.
When you make a piece of steel (like a needle), all of the tiny domain-magnets inside tend to get stuck pointing in different directions, which means that they more or less cancel each-other out, so to begin with the needle does not behave much like a magnet at all.However, if you bring the needle close to another magnet of some kind, because of the other magnet you are holding it near, the little domain magnets in your needle will tend to line up so that they are pointing along the same direction. The domains in the needle will do the same thing, and after you take the needle away from the other magnet, the domains in the needle will tend to stay pointing this way (they sort of get stuck pointing in the same direction).
Magnets attract other magnets , and also attract some kinds of metal.