This relies on a general fact about splitting fields.
Let $F$ be a field and $f(X)\in F[X]$ be a monic polynomial. An extension field $K$ of $F$ is a splitting field for $f$ if
- $f(X)=(X-a_1)(X-a_2)\dots(X-a_k)$ in $K[X]$ (the roots need not be distinct);
- $K=F(a_1,a_2,\dots,a_k)$
Theorem. If $K_1$ and $K_2$ are splitting fields of $f(X)\in F[X]$, then there exists a field isomorphism $\varphi\colon K_1\to K_2$ leaving $F$ pointwise fixed.
The proof is longish and can be found in any book on Galois theory, because it's a basic tool thereof.
Now consider the polynomial $X^{p^n}-X\in\mathbb{F}_p[X]$, where $\mathbb{F}_p$ is the $p$-element field (which is unique up to unique isomorphism).
Let $K$ be a splitting field of $f(X)$. Then $f(X)$ has $p^n$ distinct roots in $K$ (because the derivative of the polynomial is $-1$). On the other hand, the set of roots of $f(X)$ is a subfield of $K$: indeed, if $a,b$ are roots, then
$$
(a+b)^{p^n}-(a+b)=a^{p^n}+b^{p^n}-a-b=0
$$
so $a+b$ is a root of $f$. Analogously
$$
(ab)^{p^n}-ab=a^{p^n}b^{p^n}-ab=ab-ab=0
$$
and it's easy to check the reciprocals. Since also $0$ and $1$ are roots we're done.
Thus $K$ is the set of all roots of $f$ and therefore $|K|=p^n$.
Conversely, if $K$ is a field with $p^n$ elements, then the same argument as before shows that $X^{p^n}-X$ has $p^n$ distinct roots in $K$, so $K$ is a splitting field for $f(X)$.
Uniqueness up to isomorphism now follows from the theorem above.