A magnet can be considered as the sum of many small magnetic domains, which may be only a few microns or smaller in size. Each domain carries its own small magnetic field, which can point in any direction. When all the domains are pointing in the same direction, the fields add up, yielding a strong magnet. When these all point in random directions, they cancel each other, and the net magnetic field is zero.