A joint distribution over many variables is hopeless to write down directly: 30 binary variables need a billion probabilities. Structure saves us, and the key structural idea is conditional independence: once you know a common cause, its effects carry no further information about each other.
We will multiply given the cause and finish with averaging over the cause.
Step 1: Independent given the cause
X and Y are conditionally independent given Z, written X ⊥ Y | Z, if once Z is known their probabilities multiply:
Two tests for the same disease D are typically independent given the disease: each errs for its own reasons, so among people known to have D, A's result says nothing more about B, and the same holds among people known not to have D. If both tests detect the disease with probability 0.9, a sick person tests positive on both with probability 0.81. This is not independence in the whole population, and neither test causes the other.
Step 2: Averaging over the cause
Unconditionally, condition on Z and add up over its values:
Thinking in counts helps. With prevalence 0.2 and tests positive with probabilities 0.9 and 0.8 when D is present and 0.1 and 0.2 when it is absent: out of 1,000 people, 200 are sick, and 200 × 0.9 × 0.8 = 144 of them test positive on both; of the 800 healthy, 800 × 0.1 × 0.2 = 16 do. So 160 people, a share 0.16, are positive on both.