In the Book of Why by Judea Pearl (page 14) he says to work out the effect a drug (D) will have on a patients lifespan (L) taking into account other factors (Z) can be calculated as P(L | D, Z) x P(Z)
What is the purpose of multiplying by P(Z) when trying to calculate the effect of D on L?
Well, if the event of taking the drug is independent of the other factors, then :
$$\mathsf P(L, Z\mid D)=\mathsf P(L\mid D,Z)~\mathsf P(Z)$$
And so, by the Law of Total Probability:
$$\mathsf P(L\mid D)=\sum_{Z\in\mathcal Z}\mathsf P(L\mid D,Z)~\mathsf P(Z)$$
Where $\mathcal Z$ is the set of other factors.
For each $Z$ in $\mathcal Z$, $\mathsf P(L\mid D,Z)$ measures the effect of taking the drug among a 'test' group with specified other factors, and $\mathsf P(Z)$ measures the proportion of subjects with those other factors in the 'wild'. So therefore $\mathsf P(L\mid D)$ predicts the average effect of taking the drug among the 'wild'