Why would we require $p_1 = p_2$ in order for $A_1$ and $A_2$ to be independent? Furthermore, how does $B$ change anything? I have the following example:

There are two coins, labeled 1 and 2, either or both of which are possibly biased. The probability of a head is
$$P(H \mid \text{coin} \ i) = p_i, \ \ \ \ (i = 1, 2).$$
Choose a coin at random and toss it twice. Define events $A_j = \{ \text{$H$ occurs on the $j^{\text{th}}$ toss} \} \ (j = 1, 2)$, and $B = \{ \text{coin 1 is chosen} \}$. Then
(i) $A_1$ and $A_2$ are not independent unless $p_1 = p_2$.
(ii) Given $B$, $A_1$ and $A_2$ are independent events.

I'm having trouble understanding this. Why would we require $p_1 = p_2$ in order for $A_1$ and $A_2$ to be independent? After all, if $H$ occurs on one toss, then I don't see how that would affect $H$ occurring for the other toss. Furthermore, how does $B$ change anything? I don't see how the event $B$ changes anything for $A_j$ at all.
EDIT: For the record, it's possible that this example is incorrect, so there's no obligation to justify its correctness.
 A: I believe the statements are correct. Keep in mind that independence is defined through probabilities, so those are up for inspection.
If two events $A_1$ and $A_2$ are independent, then $P(A_1) = P(A_1|A_2)$, meaning that if you knew that the second coin toss resulted in heads, it will not affect the probability of the first coin toss being heads. Or in other words, the probability of the first toss being heads is the same whether the second toss is heads or tails $P(A_1|A_2) = P(A_1|\bar{A_2})$.
In this example, the event $A_1$ can occur in two ways: coin 1 is chosen and the first toss results in heads, or coin 2 is chosen and the first toss results in heads, and we have that $$P(A_1) = P(B)\cdot P(A_1|B) + P(\bar{B}) \cdot P(A_1|\bar{B})$$
$$P(A_1|B) = p_1, \,\,P(A_1|\bar{B}) = p_2.$$
(ii) Just states that if you toss the same coin twice, the probability of the outcome of the first toss is unaltered by the outcome of the second toss, and vice versa. However, since your two coins do not necessarily have the same probability for heads, it does matter which coin you toss.
(i) To see that this point is valid, it can be useful to look at extremes. Let $p_1>0$ and $p_2= 0$. If the second toss results in heads, then you can be certain that you are tossing coin 1, and hence $P(A_1) = p_1$ since you now know that $P(B) = 1$ and $P(\bar{B}) = 0$, so clearly occurence of $A_2$ gives information about $P(A_1)$. For $p_1 = p_2$, the outcome of the second coin toss does not provide any information regarding which coin was tossed, but for $p_1 \neq p_2$, $P(B)$ can be updated accordingly.
A: Note: please edit this answer if you can make it more intuitive, or if any corrections are needed.
For independence we need $Pr(A_1 \cap A_2) = Pr(A_1) Pr(A_2)$.
The probabilities of events $A_i$ depend on $B$, so we start with $Pr(A_1 \cap A_2 | B)$.
$Pr(A_1 \cap A_2 | B)  = Pr(A_1 | A_2 \cap B) Pr(A_2 | B) = Pr(A_1 | B) Pr(A_2 | B)$.
The last equality is because the two coin tosses are independent once a $B$ has been selected.
To remove the dependence of the event B we require the probabilities of the coins to be the same. $Pr(A_1 | B) = $Pr(A_1) when the probabilities of the two coins are the same because then the coins are identical, and whichever is selected will yield the same probabilities of returning a head. The same applies to $A_2$.
So we have that $Pr(A_1 \cap A_2 | B)  = Pr(A_1) Pr(A_2)$. Since the RHS does not depend in $B$ the LHS cannot either and hence we get the independence definition.
