[proofplan]
We construct two maps — pullback and "evaluation at coordinate functions" — between the set of morphisms $\mathrm{Mor}(V, W)$ and the set of $k$-algebra homomorphisms $\mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V)$, and verify they are mutual inverses. The forward map sends $\varphi$ to its pullback $\varphi^* : f \mapsto f \circ \varphi$, which is well-defined as a $k$-algebra homomorphism by elementary properties of pullback. The backward map sends $\psi : \mathcal{O}_W \to \mathcal{O}_V$ to the morphism $\Phi_\psi : V \to \mathbb{A}^m_k$ whose components are the images $\psi(\bar{Y}_j)$ of the coordinate functions $\bar{Y}_j \in \mathcal{O}_W$; the substantive content is that $\Phi_\psi$ in fact lands in $W$, which is forced by $\psi$ respecting the relations of $\mathcal{O}_W$. Mutual inverseness is then a direct computation on coordinate functions.
[/proofplan]
[step:Fix presentations of $V$ and $W$ and identify their coordinate rings]
Suppose $V \subset \mathbb{A}^n_k$ is the affine variety cut out by an ideal $I_V \subset k[X_1, \ldots, X_n]$, and $W \subset \mathbb{A}^m_k$ is cut out by an ideal $I_W \subset k[Y_1, \ldots, Y_m]$. By definition of the coordinate ring of an affine variety,
\begin{align*}
\mathcal{O}_V &= k[X_1, \ldots, X_n]/I(V), \\
\mathcal{O}_W &= k[Y_1, \ldots, Y_m]/I(W).
\end{align*}
Write $\bar{X}_i \in \mathcal{O}_V$ and $\bar{Y}_j \in \mathcal{O}_W$ for the residue classes of the coordinate variables. The coordinate ring is a $k$-algebra, with $k$ embedded via constants.
Recall also that an element $\bar f \in \mathcal{O}_V$ is naturally a function $V \to k$, with $\bar f(p) := f(p)$ for any representative $f \in k[X_1, \ldots, X_n]$ — the value is independent of the representative because two representatives differ by an element of $I(V)$ which vanishes on $V$. Thus $\mathcal{O}_V$ is realised concretely as the $k$-algebra of polynomial functions on $V$.
A morphism $\varphi : V \to W$ is by definition a map of the form
\begin{align*}
\varphi : V &\to W \subset \mathbb{A}^m_k \\
p &\mapsto (\varphi_1(p), \ldots, \varphi_m(p))
\end{align*}
with each $\varphi_j$ a polynomial function on $V$ (i.e. an element of $\mathcal{O}_V$), and with image landing in $W$.
[/step]
[step:Define the pullback map $\Phi : \mathrm{Mor}(V, W) \to \mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V)$]
Given a morphism $\varphi : V \to W$, define the pullback as the map
\begin{align*}
\varphi^* : \mathcal{O}_W &\to \mathcal{O}_V \\
\bar f &\mapsto \bar f \circ \varphi.
\end{align*}
Concretely, if $\bar f$ is represented by $f \in k[Y_1, \ldots, Y_m]$, then $\bar f \circ \varphi$ is the polynomial function $p \mapsto f(\varphi_1(p), \ldots, \varphi_m(p))$ on $V$, which is a polynomial function on $V$ since each $\varphi_j$ is.
\emph{Well-definedness on residue classes.} If $\bar f = \bar f'$ in $\mathcal{O}_W$, then $f - f' \in I(W)$ and so $(f - f')(q) = 0$ for every $q \in W$. Since $\varphi(p) \in W$ for all $p \in V$ (this is part of being a morphism into $W$), we have $(f - f')(\varphi(p)) = 0$, so $f \circ \varphi$ and $f' \circ \varphi$ agree as functions on $V$. Hence $\varphi^*$ is well-defined.
\emph{$k$-algebra homomorphism.} For $\bar f, \bar g \in \mathcal{O}_W$ and $c \in k$, evaluating at any $p \in V$:
\begin{align*}
\varphi^*(\bar f + \bar g)(p) &= (f + g)(\varphi(p)) = f(\varphi(p)) + g(\varphi(p)) = \varphi^*(\bar f)(p) + \varphi^*(\bar g)(p), \\
\varphi^*(\bar f \cdot \bar g)(p) &= (f g)(\varphi(p)) = f(\varphi(p)) \cdot g(\varphi(p)) = \varphi^*(\bar f)(p)\, \varphi^*(\bar g)(p), \\
\varphi^*(c)(p) &= c(\varphi(p)) = c = c(p),
\end{align*}
where the last line uses that the constant polynomial $c \in k$ takes the same value at every point. Hence $\varphi^*$ is a $k$-algebra homomorphism, and we set $\Phi(\varphi) := \varphi^*$.
[/step]
[step:Define the candidate inverse $\Psi : \mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V) \to \mathrm{Mor}(V, W)$]
Given a $k$-algebra homomorphism $\psi : \mathcal{O}_W \to \mathcal{O}_V$, define a candidate map $\Phi_\psi : V \to \mathbb{A}^m_k$ by
\begin{align*}
\Phi_\psi : V &\to \mathbb{A}^m_k \\
p &\mapsto \big(\psi(\bar{Y}_1)(p), \ldots, \psi(\bar{Y}_m)(p)\big).
\end{align*}
Each component $\psi(\bar{Y}_j) \in \mathcal{O}_V$ is a polynomial function on $V$, so $\Phi_\psi$ is given by polynomial functions in each coordinate. We must check that $\Phi_\psi(p) \in W$ for every $p \in V$, i.e. that the image lies in $W$.
[claim]
For every $g \in I(W)$ and every $p \in V$, $g(\Phi_\psi(p)) = 0$
[/claim]
[proof]
Pick any $g \in I(W)$. Then by definition of $I(W)$, $\bar g = 0$ in $\mathcal{O}_W$. Since $\psi : \mathcal{O}_W \to \mathcal{O}_V$ is a ring homomorphism, $\psi(\bar g) = \psi(0) = 0$ in $\mathcal{O}_V$.
Now we compute $\psi(\bar g)$ in terms of $g$. Because $\psi$ is a $k$-algebra homomorphism, it commutes with polynomial expressions: writing $g = g(Y_1, \ldots, Y_m) \in k[Y_1, \ldots, Y_m]$ (a polynomial in the coordinate variables), we have $\bar g = g(\bar{Y}_1, \ldots, \bar{Y}_m)$ in $\mathcal{O}_W$, and applying $\psi$:
\begin{align*}
\psi(\bar g) = \psi\big(g(\bar{Y}_1, \ldots, \bar{Y}_m)\big) = g\big(\psi(\bar{Y}_1), \ldots, \psi(\bar{Y}_m)\big).
\end{align*}
The first equality is the polynomial expression for $\bar g$; the second uses that $\psi$ preserves $k$-linear combinations and products and so commutes with evaluation of any polynomial.
Therefore $g(\psi(\bar{Y}_1), \ldots, \psi(\bar{Y}_m)) = 0$ as an element of $\mathcal{O}_V$, i.e. as a function on $V$. Evaluating at $p \in V$,
\begin{align*}
g\big(\psi(\bar{Y}_1)(p), \ldots, \psi(\bar{Y}_m)(p)\big) = 0.
\end{align*}
The left-hand side is precisely $g(\Phi_\psi(p))$. So $g(\Phi_\psi(p)) = 0$, as required.
[/proof]
The claim shows that for every $p \in V$, $\Phi_\psi(p)$ is killed by every element of $I(W)$, so $\Phi_\psi(p) \in V(I(W))$. By the [Hilbert Nullstellensatz](/theorems/2124) applied to varieties, $V(I(W)) = W$ (the closure of $W$ is $W$ itself, as $W$ is closed). Hence $\Phi_\psi(p) \in W$, so $\Phi_\psi$ is a map $V \to W$ given coordinate-wise by polynomials, i.e. a morphism. Set $\Psi(\psi) := \Phi_\psi$.
[guided]
We are constructing the candidate inverse to pullback. Given $\psi : \mathcal{O}_W \to \mathcal{O}_V$, what is the corresponding map of varieties? The right answer is: track where the coordinate functions go.
\textbf{Why the coordinate functions?} The coordinate functions $\bar{Y}_1, \ldots, \bar{Y}_m \in \mathcal{O}_W$ generate $\mathcal{O}_W$ as a $k$-algebra (they are the images of the polynomial generators $Y_1, \ldots, Y_m$ under the quotient map). A $k$-algebra homomorphism $\psi$ is determined by where it sends the generators. So all the data of $\psi$ is encoded in $\psi(\bar{Y}_1), \ldots, \psi(\bar{Y}_m) \in \mathcal{O}_V$.
\textbf{The candidate map.} For $p \in V$, define
\begin{align*}
\Phi_\psi(p) := \big(\psi(\bar{Y}_1)(p), \ldots, \psi(\bar{Y}_m)(p)\big) \in \mathbb{A}^m_k.
\end{align*}
The components $\psi(\bar{Y}_j)$ are polynomial functions on $V$, so the map is polynomial in coordinates. The only non-trivial check is that the image lies in $W$.
\textbf{Why does $\Phi_\psi(p)$ land in $W$?} A point $q \in \mathbb{A}^m_k$ lies in $W$ iff $g(q) = 0$ for every $g \in I(W)$. So we must show: for every $g \in I(W)$ and every $p \in V$,
\begin{align*}
g\big(\psi(\bar{Y}_1)(p), \ldots, \psi(\bar{Y}_m)(p)\big) = 0.
\end{align*}
The argument has two ingredients:
\begin{enumerate}
\item Algebra: $\psi$ kills $\bar g$ because $\bar g = 0$ in $\mathcal{O}_W$ (since $g \in I(W)$). Hence $\psi(\bar g) = 0$ in $\mathcal{O}_V$.
\item Polynomial functoriality: $\psi$ is a $k$-algebra homomorphism, so it commutes with polynomial expressions. Spelling out $\bar g = g(\bar{Y}_1, \ldots, \bar{Y}_m)$ and applying $\psi$ termwise:
\begin{align*}
\psi(\bar g) = g\big(\psi(\bar{Y}_1), \ldots, \psi(\bar{Y}_m)\big).
\end{align*}
\end{enumerate}
Combining, $g(\psi(\bar{Y}_1), \ldots, \psi(\bar{Y}_m)) = 0$ as a function on $V$. Evaluating at $p$ gives the displayed equation, hence $\Phi_\psi(p) \in W$.
\textbf{Where does the variety structure on $W$ enter?} The proof crucially uses that $\bar g = 0$ in $\mathcal{O}_W = k[Y_1, \ldots, Y_m]/I(W)$ exactly when $g \in I(W)$. The relations $g \in I(W)$ are encoded in the quotient $\mathcal{O}_W$ by being set to zero; the homomorphism $\psi$ must respect these relations because it is well-defined on $\mathcal{O}_W$, not on the polynomial ring. So a $k$-algebra map out of the quotient is automatically the "right" object to define a morphism into $W$.
[/guided]
[/step]
[step:Verify $\Phi \circ \Psi = \mathrm{id}$ on $\mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V)$]
Take $\psi \in \mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V)$ and let $\varphi := \Psi(\psi) = \Phi_\psi$. We must show $\varphi^* = \psi$ as maps $\mathcal{O}_W \to \mathcal{O}_V$. Both are $k$-algebra homomorphisms with the same domain and codomain; since $\mathcal{O}_W$ is generated as a $k$-algebra by $\bar{Y}_1, \ldots, \bar{Y}_m$, it suffices to check that $\varphi^*$ and $\psi$ agree on each generator $\bar{Y}_j$.
By definition of pullback, $\varphi^*(\bar{Y}_j) = \bar{Y}_j \circ \varphi$, which is the function $p \mapsto Y_j(\varphi(p)) = \varphi_j(p)$ — i.e. the $j$-th component of $\varphi$. By construction of $\Phi_\psi$, that $j$-th component is $\psi(\bar{Y}_j)$. Hence
\begin{align*}
\varphi^*(\bar{Y}_j) = \psi(\bar{Y}_j) \qquad \text{for each } j = 1, \ldots, m.
\end{align*}
Two $k$-algebra homomorphisms agreeing on generators are equal, so $\varphi^* = \psi$, i.e. $\Phi(\Psi(\psi)) = \psi$.
[/step]
[step:Verify $\Psi \circ \Phi = \mathrm{id}$ on $\mathrm{Mor}(V, W)$]
Take $\varphi \in \mathrm{Mor}(V, W)$ and let $\psi := \Phi(\varphi) = \varphi^*$. We must show $\Phi_\psi = \varphi$ as maps $V \to W$.
By definition of $\Phi_\psi$, the $j$-th component of $\Phi_\psi(p)$ is
\begin{align*}
\psi(\bar{Y}_j)(p) = \varphi^*(\bar{Y}_j)(p) = (\bar{Y}_j \circ \varphi)(p) = Y_j(\varphi(p)) = \varphi_j(p),
\end{align*}
where the third equality uses the definition of the pullback action $\varphi^*(\bar f) = \bar f \circ \varphi$ on the function $\bar{Y}_j$, and the fourth uses that the polynomial $Y_j$ at the point $\varphi(p) = (\varphi_1(p), \ldots, \varphi_m(p)) \in W$ extracts the $j$-th coordinate. Hence $\Phi_\psi(p) = (\varphi_1(p), \ldots, \varphi_m(p)) = \varphi(p)$ for every $p \in V$, so $\Phi_\psi = \varphi$, i.e. $\Psi(\Phi(\varphi)) = \varphi$.
[/step]
[step:Conclude the bijection and naturality]
Combining Steps 4 and 5, $\Phi$ and $\Psi$ are mutually inverse maps between $\mathrm{Mor}(V, W)$ and $\mathrm{Hom}_{k\text{-alg}}(\mathcal{O}_W, \mathcal{O}_V)$. They are bijections.
Naturality (functoriality) follows by direct check: for morphisms $\varphi : V \to W$ and $\sigma : W \to Z$ of affine varieties,
\begin{align*}
(\sigma \circ \varphi)^*(\bar f) = \bar f \circ \sigma \circ \varphi = \varphi^*(\bar f \circ \sigma) = \varphi^*(\sigma^*(\bar f)) = (\varphi^* \circ \sigma^*)(\bar f),
\end{align*}
so $(\sigma \circ \varphi)^* = \varphi^* \circ \sigma^*$, and $(\mathrm{id}_V)^* = \mathrm{id}_{\mathcal{O}_V}$. The correspondence $\varphi \leftrightarrow \varphi^*$ is therefore a contravariant equivalence between the category of affine varieties over $k$ and the category of finitely generated reduced $k$-algebras, restricted to the morphism sets in the statement.
[/step]