First, you have a few typos.
$\dot{\rho}=-3H(\rho+P)$
$H^2=\frac{8\pi{G}\rho}{3}$ and $\frac{\ddot{a}}{a}=-\frac{4\pi{G}\rho}{3}(\rho+3P)$ for $c=1$
Actually, we can derive the Fluid equation by just using the first law of thermodynamics,
$$dQ=dE+PdV$$
so in derivation we don't need to use The Friedmann Equation or The Acceleration equation.
The fluid equation describes the relationship between $\rho$ and $a(t)$ in terms of $w$ where, $P=w\rho$.
So, if we solve the Fluid equation we would get $$\rho(t)=\rho_0a(t)^{-3(1+w)}$$$$\rho(a)=\rho_0a^{-3(1+w)}$$
For every type of matter in the universe we have different values of $w$ so for every component we would get different $\rho$ and $a(t)$ relationship.Hence we need to define them separately
Now Lets suppose we have 2 components mattter and radiation. Then the total density can be written as, $$\rho_{tot}(t)=\rho_m(t)+\rho_r(t)$$$$\rho_{tot}(a)=\rho_m(a)+\rho_r(a)$$ so we have $$\rho_{tot}(t)=\rho_{m,0}a^{-3}+\rho_{r,0}a(t)^{-4}$$$$\rho_{tot}(a)=\rho_{m,0}a^{-3}+\rho_{r,0}a^{-4}$$
This is the form that we can put into the Friedmann Equations.
Hope this helps.