Your contrapositive is correct.
To actually prove the contrapositive, use the hint they've given. Suppose that \(p\) is composite. Then there exists a prime factor \( p_1 \) of \(p\). However, carefully note that because \(p_1\) is a prime divisor of \(p\), that \(1 < p_1 < p\).
We wish to only prove a "there-exists" statement as you correctly stated, so we may choose our values for \(a\) and \(b\). Make the specific choice \(a=p_1\) and \(b=\frac{p}{p_1}\) as they've given in the hint. Then on one hand, it is clearly true that \( ab = p \), so the obvious fact that \( p\mid p\) implies \(p\mid ab\).
On the other hand, we know that \(p_1 < p\). Therefore it's impossible that \( p \mid p_1 \), since no integer is divisible by any integer less than it. Therefore \( p\not\mid a\).
Likewise, since \(p_1 > 1\), it follows that \(\frac{p}{p_1} < \frac{p}{1} = p\). That is, \( \frac{p}{p_1}\) is also an integer strictly less than \(p\). Hence \(p \not\mid \frac{p}{p_1} \), i.e. \(p \not\mid b\).
And the contrapositive has now been proven.