Here is one way to prove it, which shows not only that all maximal ideals have the same height but that all maximal chains of prime ideals have the same length (and this is true in any affine domain, not just a polynomial ring). The key ingredient is the following lemma.

**Lemma**: Let $k$ be a field and $A$ be an affine domain of transcendence degree $d$ over $k$. Let $P\subset A$ be a height $1$ prime. Then $A/P$ has transcendence degree $d-1$ over $k$.

*Proof*: By Noether normalization, there exist algebraically independent elements $x_1,\dots,x_d\in A$ such that $A$ is integral over $B=k[x_1,\dots,x_d]$. Then $P\cap B$ is a height $1$ prime of $B$ ($P\cap B\neq 0$ by incomparability of primes lying over the same prime in an integral extension, and there can be no nonzero prime strictly contained in $P\cap B$ by going down). But $B$ is just a polynomial ring and in particular a UFD, so this means $P\cap B$ is generated by some irreducible polynomial $f\in B$. It follows that $B/(P\cap B)$ has transcendence degree $d-1$ over $k$ (explicitly, if $x_i$ is a variable that appears in $f$, then the other $d-1$ variables are still algebraically independent mod $f$ but $x_i$ is algebraically dependent over them via $f$). Since $A/P$ is integral and thus algebraic over $B/(P\cap B)$, $A/P$ also has transcendence degree $d-1$ over $k$.

Given the Lemma, we can then prove the following theorem.

**Theorem**: Let $k$ be a field and $A$ be an affine domain over $k$. Then every maximal chain of prime ideals in $A$ has length equal to the transcendence degree of $A$ over $k$.

*Proof*: Let $d$ be the transcendence degree of $A$ over $k$ and let $0=P_0\subset P_1\subset\dots\subset P_n$ be a maximal chain of prime ideals in $A$. By induction on $i$ using the Lemma, $A/P_i$ has transcendence degree $d-i$ for each $i$, and in particular $A/P_n$ has transcendence degree $d-n$. But by Zariski's lemma, $A/P_n$ is algebraic over $k$ (since $P_n$ is a maximal ideal so $A/P_n$ is a finitely generated algebra over $k$ which is a field). Thus $d-n=0$ so $d=n$, as desired.