We present a detailed analysis of the role of the magnetic dipole-dipole interaction in cold and ultracold collisions. We focus on collisions between magnetically trapped NH molecules, but the theory is general for any two paramagnetic species for which the electronic spin and its space-fixed projection are (approximately) good quantum numbers. It is shown that dipolar spin relaxation is directly associated with magnetic-dipole induced avoided crossings that occur between different adiabatic potential curves. For a given collision energy and magnetic field strength, the cross-section contributions from different scattering channels depend strongly on whether or not the corresponding avoided crossings are energetically accessible. We find that the crossings become lower in energy as the magnetic field decreases, so that higher partial-wave scattering becomes increasingly important textit{below} a certain magnetic field strength. In addition, we derive analytical cross-section expressions for dipolar spin relaxation based on the Born approximation and distorted-wave Born approximation. The validity regions of these analytical expressions are determined by comparison with the NH + NH cross sections obtained from full coupled-channel calculations. We find that the Born approximation is accurate over a wide range of energies and field strengths, but breaks down at high energies and high magnetic fields. The analytical distorted-wave Born approximation gives more accurate results in the case of s-wave scattering, but shows some significant discrepancies for the higher partial-wave channels. We thus conclude that the Born approximation gives generally more meaningful results than the distorted-wave Born approximation at the collision energies and fields considered in this work.