Differences between formulae for dipole–dipole interaction energy
They are both dipole-dipole energies as from the link but their contexts are different. Eq. 3 (as numbered in the LibreTexts link),
$$V(r) = - \frac{\mu_{1}\mu_{2}}{4\pi\epsilon_{0}r^{3}} \tag{3}$$
is specifically for the case when the dipoles are aligned. The more general Eq. 4
$$V(r) = - \frac{\mu_{1}\mu_{2}}{4\pi\epsilon_{0}r^{3}_{12}} (\cos\theta_{12} - 3\cos\theta_{1}\cos\theta_{2}) \tag{4}$$
is preferable because it includes the dependence on the orientation of the dipoles in space. And I believe Eq. 7
$$V = - \frac{2\mu_{\mathrm{A}}^{2}\mu_{\mathrm{B}}^{2}}{3(4\pi\epsilon_{0})^{2}r^{6}} \frac{1}{k_{\mathrm{B}}T} \tag{7}$$
is the energy derived by thermally averaging the dipole–dipole energies when the dipoles are fixed in space but are free to rotate.
So Eq. 3 is the dipole–dipole energy when the dipoles are both in a specific orientation, Eq. 4 reveals the orientational dependence of the dipole-dipole energy, and Eq. 7 is the thermally averaged energy for two dipoles that have a fixed separation $r$ but are free to rotate.