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][1] is a student project which gives a very detailed proof of this statement, without using any heavy machinery beyond the definitions. 

(See also [this question][2] for more discussion and references -- in particular Paul Monsky's answer sketches much slicker but less elementary approach via Hilbert's theorem 90.)


  [1]: https://www.ma.imperial.ac.uk/~tc4117/assets/2-Torsion%20in%20Ideal%20Class%20Groups.pdf
  [2]: https://mathoverflow.net/questions/141150/2-class-group-of-a-quadratic-imaginary-extension