If neither I nor J is contained in P, some element a in I and b in J are neither in P, as you say. But this is a contradiction, since ab is in P and P is prime, hence one of the ideals is contained in P.
Follow-up: Show this for an arbitrary finite number of ideals.
obviously if either I or J is a subset of P, there is nothing to prove. so to negate that, we need some a in I with a NOT in P, AND b in J with b NOT in P.
but since I is an ideal, ab is in I. since J is an ideal ab is in J. therefore ab is in I∩J, and thus in P. since P is prime, either a is in P, contradicting our choice of a, or b is in P, contradicting our choice of b.
the only conclusion is that we cannot pick such a in I AND b in J outside of P, either I or J must lie within P.
Exactly. So if we can pick an a in I not in P, we cannot pick a b in J not in P. Hence if I is not contained in P, J must be contained in P. Oppositely, if J is not contained in P, I must be contained in P.