Fall of the number density $n$ with the scale factor $a(t)$ for a relativistic particle species in equilibrium? Consider the thermal dark matter (DM) scenario. Before the dark matter got frozen out, it was both in chemical and thermal equilibrium with the other particles in the early universe. At this point of time, when the dark matter was in equilibrium, the number densities of both the DM and the relativistic particles with which it were equilibrium depleted with the fall of temperature as $$n\propto T^3\tag{1}$$ where $T$ is the temperature of the universe. 
Intuitively, the depletion in the number density with the expansion of the Universe should be like $$n\propto a^{-3}(t)\tag{2}$$ where $a(t)$ is the scale factor.
Now, my question is, whether the relations (1) and (2) are related. And intuitively, they should be because the fall in temperature is due to the expansion of the Universe. And if they are, how do we get relation (1) from (2)?
 A: The basic principle that is useful for addressing the issue you are talking about is conservation of entropy. In thermal equilibrium, the comoving entropy is conserved, and this can be used to find out how the temperature changes with the expansion of the universe. 
Since the entropy density of relativistic species usually dominate the total entropy, it is useful to define the total entropy in terms of an effective number of relativistic degrees of freedom (for entropy), $g_{*\text{S}}$
\begin{equation}
s_\text{tot} = g_{*\text{S}} \frac{2 \pi^2}{45}T^3,
\end{equation}
where
\begin{equation}
g_{*\text{S}} = \sum_{\text{bosons}} g_i \left(\frac{T_i}{T}\right)^3 + \frac{7}{8} \sum_{\text{fermions}} g_i \left(\frac{T_i}{T}\right)^3,
\end{equation}
where $T$ is the temperature of the heat bath, and we have allowed for the possibility that some relativistic species have decoupled from the heat bath and have a different temperature, $T_i$. Note that we have also assumed here that the chemical potentials are negligible. 
Assuming that the comoving entropy density is constant in time we get
\begin{equation}
\frac{d }{d t} \left(s a^3\right) = 0.\tag{1}
\end{equation}
This means that we can directly relate the temperature, $T$, and the scale factor, $a$
\begin{equation}
T \propto \frac{g_{*\text{S}}^{-1/3}(T)}{a}.\tag{2}
\end{equation}
So we see that as long as the number of relativistic degrees of freedom, $g_{*\text{S}}$, does not change then we have $T \sim 1/a$, and your (1) and (2) are compatible. 
If the number of relativistic degrees of freedom changes, then your equation (2) is not valid any more. This is because heat is either added to or subtracted from the heat bath, increasing or decreasing the comoving number of particles of any given species. 
(1) will always be valid, however, as long as a species is in thermodynamic equilibrium (with no chemical potential). 
