# What determines if magnetic spins align parallel or anti parallel in a material?

As we all know, the magnetic field around a dipole looks like the following:

Notice how, directly above and below the magnet, the magnetic fields likes are parallel to the north-south axis. However, to the sides of the magnet, the magnetic field lines are anti parallel. If you've ever played with a magnet, you know that magnets, when placed end-to-end, like to align parallel, but when placed side by side like to align anti-parallel:

Now let's zoom into some magnetic material. It's made up of a bunch of elementary magnetic spins. Given the direction of the magnetic field lines, it's not clear which is more energetically favorabe: for all spins to point in the same direction, or for them to "flip" in a checkerboard pattern:

Is there a reason we always think about the first configuration and not the second? What property of a material decides whether the spins will all be aligned parallel or anti parallel?