the answer is The magnetic field’s strength decreases as distance increases. In fact, a magnet’s power can all but disappear when it’s moved even a slight distance away from the compass. However, stronger magnets can continue to influence the direction of the compass’ needle from greater distances away.
Why?
This is because the bar magnets were competing with the earth’s own magnetic field, which pulls the tip of the compass needle north. As you scooted each bar magnet progressively closer to the compass, the magnet’s field started to take over, pulling the needle slightly away from north. When you joined multiple bar magnets together, you created one large super magnet that has the power of all of the smaller magnets’ magnetic fields combined.