If $A$ is a ring, also known as a $\mathbf{Z}$-algebra, then ring maps from $\mathbf{Z}[X_1,\ldots,X_n]$ to $A$ are the same as $n$-tuples of elements of $A$. This is the universal property of the polynomial ring:
$\mathrm{Hom}_{\mathbf{Ring}}(\mathbf{Z}[X_1,\ldots,X_n],A)=A^n$
via $\varphi\mapsto(\varphi(X_1),\ldots,\varphi(X_n))$. A ring map $\varphi:\mathbf{Z}[X_1,\ldots,X_n]\rightarrow A$ factors through $\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m)$ if and only if each $f_i$ is sent to zero. By definition, $\varphi(f_i)=f_i(a_1,\ldots,a_n)$, where $a_i=\varphi(X_i)$. Conversely, any ring map $\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m)\rightarrow A$ gives rise to a homomorphism $\mathbf{Z}[X_1,\ldots,X_n]\rightarrow A$ which sends each $f_i$ to zero. Thus
$\mathrm{Hom}_{\mathbf{Ring}}(\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m),A)\hookrightarrow
\mathrm{Hom}_{\mathbf{Ring}}(\mathbf{Z}[X_1,\ldots,X_n],A)=A^n$
identifies the source (as a set) with the set $n$-tuples $(a_1,\ldots,a_n)\in A^n$ such that $f_i(a_1,\ldots,a_n)=0$ for $1\leq i\leq n$.
It remains to translate this to a statement about the $A$-valued points of $\mathrm{Spec}(\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m))$. This is done via the $\mathrm{Spec}$ functor, which gives an equivalence of categories between rings and affine schemes. So ring maps from $\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m)\rightarrow A$ are the same as morphisms $\mathrm{Spec}(A)\rightarrow\mathrm{Spec}(\mathbf{Z}[X_1,\ldots,X_n]/(f_1,\ldots,f_m))$.
First, note that the functor $\operatorname{Spec}:\mathtt{CRing}^{op}\to\mathtt{Sch}$ has a left adjoint, namely the functor that sends a scheme to its ring of global functions (proof: a morphism $X\to\operatorname{Spec} A$ is equivalent to a compatible family of homomorphisms $A\to B$ for each affine open $\operatorname{Spec} B$ in $X$, which by gluing is equivalent to a homomorphism $A\to\mathcal{O}_X(X)$). Thus $\operatorname{Spec}$ preserves limits, and in particular we can compute equalizers of affine schemes by just taking coequalizers of rings.
Now for an example. Let $k$ be a field, let $A=k[x]/(x^2)$, and let $f^*,g^*:A\to A$ be the identity map and the map that sends $x$ to $0$, respectively. Letting $X=\operatorname{Spec} A$, these induce morphisms $f,g:X\to X$. The coequalizer of $f^*$ and $g^*$ is just the obvious quotient map $k[x]/(x^2)\to k$ and so the equalizer of $f$ and $g$ is the corresponding map $i:\operatorname{Spec} k\to X$. This map $i$ is surjective, but $f\neq g$.
Best Answer
Following Pedro Tamaroff's comment, the correct idea should be that a scheme is a colimit (gluing) of affine schemes, and as $\rm Hom$ functors preserve colimits, this means that once you know $\rm {Hom}(Y,X)$ for all affine schemes, you can compute what $\rm{Hom}(Y,X)$ has to be for general schemes by writing $Y$ as a colimit of affines.
The details of the statement "every scheme is a colimit of affine schemes" are basic category theory, but you have to find the correct lens to look through. This MO post gives complete details.