The force lines of the same poles push against each other, While with opposite poles the force lines push and pull in the same direction.
Magnetism creates force lines. The force lines push out of one end of the magnetic field and return or are "pulled in" on the other side of the magnet.
Magnets with the same pole push against each other. Each magnet produces a force field pushing out. These fields oppose each other.
A fun and simple experiment is to place two magnets under a plastic sheet. Put the two poles facing each other a few inches apart. Then sprinkle iron filings on the plastic sheet. The magnetic force fields will cause the iron filings will show a blank area between the two magnets and the force fields curving away from the area between the two magnets.
Magnets with opposite poles work together. The force field from one magnet will "push out" while the force field on the other magnet will "draw, pull in" the force field. Both force fields are creating a force in the same direction.
Do the same experiment with the magnets, plastic sheet and iron filings. This time place the magnets with the North and South poles facing each other. The iron fillings will form strong lines connecting the two magnets. These force lines show the attraction between the two magnets.