Help in a proof in basic Algebraic Geometry I'm trying to understand this proof:
Theorem
Let $X$ and $Y$ be affine closed sets. If $f:X\to Y$ is a function such that $g\circ f\in k[X]$ for every $g\in K[Y]$, then $f$ is a morphism.
Proof
Suppose that $f:X\to Y$ is a function such that $g\circ f\in k[X]$, whenever $g\in k[Y]$. We write $f=(f_1,\ldots,f_m)$ and take $g=s_i\in k[Y]$ the regular function corresponding to the polynomial $S_i\in k[S_1,\ldots S_m]$, then $s_i\circ f=f_i\in k[X]$ for each $i=a,\ldots,m$, showing $f$ is a morphism.
Remark
$k[X]$ is the coordinate ring of $X$.
My doubts
Why can we write $f=(f_1,\ldots,f_m)$? Why $s_i\circ f=f_i\in k[X]$?
Thanks in advance.

You can write $f$ in components because $Y$ is a subset of $\mathbb K^m$. The monomial $S_i$ is just the projection onto the $i$th coordinate.
