Let $x$ stand for the amount of postcards that Ron had before trading, and let $y$ stand for the amount of postcards that Matt had before trading. So, to find $x$ and $y$ we can form simple equations from the information given.
Now, if Ron had traded in half of his postcards, that means he’s got the other half left, that is, $\frac{x}{2}$, but then he got 9 in exchange from Matt, i.e. $\frac{x}{2} + 9$. Therefore $$\frac{x}{2} + 9 = 21 \implies \frac{x}{2} = 21 - 9 = 12 \\\ \implies x = 12 * 2 = 24 $$
So Ron had 24 cards.
Now remember that Matt had $y$ cards before trading. We know he traded 9 of them in, which leaves us with $y-9$, but then got half of Ron’s cards in return, 12 as we know from our previous calculation. Therefore $$ 21 = y - 9 + 12 = y + 3 \\\ y + 3 = 21 \implies y = 21 - 3 = 18 $$
So Matt had 18 cards.