I think they have got the answer like this:
Case 1) 1 white is transfrred from P to Q. Thus, Q contains 5 white and 3 black. And then 1 white is transferred from Q to P.
Case 2) 1 black is transfrred from P to Q. Thus, Q contains 4 white and 4 black. And then 1 black is transferred from Q to P.
Case 3) 1 white is transfrred from P to Q. Thus, Q contains 5 white and 3 black. And then 1 black is transferred from Q to P.
Case 4) 1 black is transfrred from P to Q. Thus, Q contains 4 white and 4 black. And then 1 white is transferred from Q to P.
Lets evaluate case 1: After the transfers are over, 3 balls white out of 7 total balls
Probablity of selecting white from P = $\frac{3}{7}$
Now, Q has 5 white balls.
Probablity of selecting white from Q = $\frac{5}{8}$
Now, probablity that after the transfers are over,
you have 3 balls white out of 7 total balls in P
= $\frac{3}{7}$ * $\frac{5}{8}$
= $\frac{15}{56}$
Lets evaluate case 2: After the transfers are over, 3 balls white out of 7 total balls
Probablity of selecting black from P = $\frac{4}{7}$
Now, Q has 4 black balls.
Probablity of selecting black from Q = $\frac{4}{8}$
Now, probablity that after the transfers are over,
you have 3 balls white out of 7 total balls in P
= $\frac{4}{7}$ * $\frac{4}{8}$
= $\frac{16}{56}$
Lets evaluate case 3: After the transfers are over, 2 balls white out of 7 total balls
Probablity of selecting white from P = $\frac{3}{7}$
Now, Q has 3 black balls.
Probablity of selecting black from Q = $\frac{3}{8}$
Now, probablity that after the transfers are over,
you have 2 balls white out of 7 total balls in P
= $\frac{3}{7}$ * $\frac{3}{8}$
= $\frac{9}{56}$
Lets evaluate case 4: After the transfers are over, 4 balls white out of 7 total balls
Probablity of selecting black from P = $\frac{4}{7}$
Now, Q has 4 white balls.
Probablity of selecting white from Q = $\frac{4}{8}$
Now, probablity that after the transfers are over,
you have 4 balls white out of 7 total balls in P
= $\frac{4}{7}$ * $\frac{4}{8}$
= $\frac{16}{56}$
Now, calculating total probablity is similar to calculating the expected value.
Now, total probablity
= $\frac{3}{7}$ * $\frac{15}{56}$ + $\frac{3}{7}$ * $\frac{16}{56}$ + $\frac{2}{7}$ * $\frac{9}{56}$ + $\frac{4}{7}$ * $\frac{16}{56}$
= $\frac{25}{56}$