Let $A$ be the event the parts were selected from the first shipment, and let $G$ be the event they are both good.
We want the probability they are from the first shipment, given they are both good. So we want $\Pr(A|G)$.
By the definition of conditional probability, we have
$$\Pr(A|G)=\frac{\Pr(A\cap G)}{\Pr(G)}.\tag{1}$$
We find the two probabilities on the right-hand side of (1).
The event $G$ can happen in two disjoint ways: (i) we select from the first shipment, and both items are good or (ii) we select from the second shipment, and both items are good.
We find the probability of (i). The probability we choose from the first shipment is $\frac{1}{2}$. Given that we selected from the first shipment, the probability they were both good is $\frac{900}{1000}\cdot \frac{899}{999}$.
Thus the probability of (i) is $\dfrac{1}{2}\cdot\dfrac{900}{1000}\cdot\dfrac{899}{999}$.
Similarly, find the probability of (ii). Add to get $\Pr(G)$.
Note that the numerator in Formula (1) is just what we called the probability of (i).
Remark: We interpreted "$10\%$ bad" literally, as in exactly $10$ percent, that is, exactly $100$ bad items in the group of $1000$. However, another reasonable interpretation is that the first shipment comes from a supplier who has a $10\%$ bad rate. Then we would replace $\frac{900}{1000}\cdot \frac{899}{999}$ by $\left(\frac{90}{100}\right)^2$. Numerically, it makes no practical difference.
The boxes have different numbers of components. So if we choose a box, and then a component, not all components are equally likely to be chosen. The ones in the smaller boxes have an edge.
An extreme example will I think make things clear. Suppose Boxes 1, 2, and 3 each hold one component, which is defective. Box 4 holds $97$ components, all of them good. It is clear that if we pick a box at random, and then a component, the probability the component chosen is bad is $3/4$. If we used Total Number of Bad divided by Total Number of Components, we would get $3/100$, very far from the truth.
Best Answer
Following on from the suggestion to use Bayes' Theorem, a verbal description should help in interpreting the formula. Part (A) In words, the probability of it being box $1$ given that the battery selected is unacceptable is the probability of selecting an unacceptable battery from box $1$ divided by the probability of selecting an unacceptable battery from either box.
In Bayes formula form, this looks like......
$P(A|B) = \frac{P(B|A)\cdot P(A)}{P(B)}$
$= \frac{0.1\cdot 0.5}{0.5\cdot 0.1+0.5\cdot 0.05}$
$= \frac{2}{3}$
Part (B) is a repeat except that we are now dealing with the probability of selecting two unacceptable batteries and not one.
$P(A|C) = \frac{P(C|A)\cdot P(A)}{P(C)}$
$$= \frac{0.1\cdot \frac{99}{999}\cdot 0.5}{0.5\cdot 0.1\cdot \frac{99}{999}+0.5\cdot 0.05\cdot \frac{99}{1999}}$$
$$= 0.80$$