It is easier than the other answers suggest.
If $k|n$ then also $\frac nk|n$, so the divisors of $n$ come in pairs unless $k=\cfrac nk$ or equivalently $n=k^2$
So the only numbers which have an odd number of divisors are squares.
Every positive integer greater than $1$ has the two divisors $1$ and $n$.
A positive integer with precisely three divisors must be a square $n=k^2$, which has divisors $1, k, n$. If $p|k$ then $p|n$ and $p$ is a further divisor unless $p=k$. So $n$ must be the square of a prime.
More generally, you may want to show that the number of divisors of $$n=p_1^{n_1}\cdot p_2^{n_2}\cdot p_3^{n_3} \dots p_r^{n_r}$$ (where this is the prime factorisation of $n$ into powers of distinct primes) $$(n_1+1)(n_2+1)(n_3+1)\dots (n_r+1)$$