Generally the differential equation for something like that is
rate of change = (total number of elements put into system at time t) - (total number elements removed at time t).
It may help to start not with a differential equation but with a difference equation, since really you're talking about a discrete process and approximating it as continuous. For the bacteria example, suppose at time t you have n_t bacteria. At the next time step the number of bacteria increases by a multiplicative factor r + 1, but then some number b of the bacteria die, so in total the number of bacteria at time t+1 is
n_{t+1} = (r + 1)n_t - b
Note that this depends on the fact that I said the bacteria multiply first, then die. I could have said some die, then multiply, in which case the right hand side would look like (r+1)(n - b), but this still looks like (r+1)n - constant, so we'll just roll with the above form. To get a differential equation, let's write the above equation as
n_{t+1}-n_t = rn_t - b
The left hand side is
\frac{n_{t+1}-n_t}{t+1 - t} \sim \frac{dn(t)}{dt},
where this is approximated as a derivative when we're looking at "time" scales much larger than the unit time step. Note that t, as I've used it, is actually dimensionless - in the resulting differential equation which I'm about to write down, the time is measured in units of some constant time parameter which hasn't explicitly been introduced in the difference equation. Anyways, in this approximation, n_t \sim n(t) and so
\frac{dn(t)}{dt} = rn(t) - b
which is what I said earlier: the rate of change is equal to the amount of bacteria we added to the system (which was rn_t) minus the amount of bacteria taken away (b).