The condition shouldn't be "$n$ is prime" but "$n$ is either 1, 2, or a prime congruent to 3 mod 4". For instance $\mathbb{Q}(-5)$ has class number 2.
The more general statement that the 2-torsion subgroup of the class group (i.e. the subgroup of elements of order 1 or 2) has order $2^{d-1}$, where $d$ is the number of prime factors of the discriminant. Here is a student project which gives a very detailed proof of this statement, without using any heavy machinery beyond the definitions.