I have read this, but I still am left with the doubt. In the proof by Hartshorne on page 19 that there is a natural bijection $\alpha$ between homsets between affine varieties and homsets between their (flipped) coordinate ring and ring of regular functions, the equality at the bottom of the pages uses this fact crucially.
In particular, I think you need that
$f(h(\overline{x_1})(P), ... h(\overline{x_n})(P)) = h(f(\overline{x_1},...,\overline{x_n}))(P)$
Where h is a $k$-algebra homomorphism between the rings of regular functions on the affine varieties $Y$ and $X$, $f$ is a polynomial in $I(Y)$, each $\overline{x_i}$ is the image of a coordinate $x_i$ in the coordinate ring $A(Y)$, and $P$ is a point in $X$, the other affine variety.
In most of the proofs I see online it seems an “obvious” detail concerning how a ring homomorphism that preserves units is a $k$-algebra homomorphism (because scalars work out), but I guess I am confused as to how exactly an arbitrary polynomial could possibly preserve units.
(I am sure I am looking at this the wrong way, I just want clarification as to how. Perhaps it is because of the isomorphism between $A(Y) \cong \mathcal{O}(Y)$ for affine varieties that we can consider the LHS a “compatible” k-algebra to begin with? Also could someone clear up what exactly the map $\overline{ }$ that sends a coordinate to its image in the appropriate polynomial ring is?)