We usually describe the forces between magnets by the "magnetic fields" created by each., i.e., the magnetic field produced by magnet 1 exerts a force on magnet 2 and vice versa. Sometimes the force is attractive, sometimes repulsive. It's often described in terms of poles, with each magnet having a north and south pole, and unlike poles attracting and like poles repelling. For simple geometries, the fields and forces can be calculated from appropriate magnetic equations. So we can describe and calculate magnetic forces in various ways, but that may not fully answer the question of WHY. The most basic answer is that the magnetic forces will try to produce motion in the direction that will lower the total energy.