The set of morphism from a tensor product to an certain ring When we try to prove the existence of fibre product in affine case, we use the following formula stacks project:
$$\newcommand{\Hom}{\mathrm{Hom}}\newcommand{\Mor}{\mathrm{Hom}}\newcommand{\Spec}{\mathrm{Spec}}
\begin{eqnarray}
\Mor(X, \Spec(A \otimes_R B))& = &
\Hom(A \otimes_R B, \mathcal{O}_X(X)) \\
& = &\Hom(A, \mathcal{O}_X(X))
\times_{\Hom(R, \mathcal{O}_X(X))}
\Hom(B, \mathcal{O}_X(X)) \\
& = & \Mor(X, \Spec(A))\times_{\Mor(X, \Spec(R))}\Mor(X, \Spec(B))
\end{eqnarray}
$$
My questions are:


*

*I don't know how do we derive the second formula.

*Moreover, some part of the third equality is also confusing to me. I know 
$$\Hom(A, \mathcal{O}_X(X))=\Mor(X, \Spec(A))$$
But what does the "fibre product" (in category of sets) notation mean?
 A: Let me start with your second question.  If $X,Y,$ and $Z$ are sets with maps $p:X\to Z$ and $q:Y\to Z$, then the fiber product $X\times_Z Y$ is the set $\{(x,y)\in X\times Y:p(x)=q(y)\}$.  (You can also define it by the exact same universal property as for fiber products of schemes, but the explicit construction is probably more helpful to think about in this context.)
Now let's look at your first question.  There is a universal property of tensor products in the category of commutative rings: namely, they are pushouts (dual to fiber products).  Here's what that means explicitly.  Let $A$ and $B$ be $R$-algebras (via homomorphisms $i:R\to A$ and $j:R\to B$), and let $k:A\to A\otimes_R B$ and $\ell:B\to A\otimes_R B$ be the natural maps ($k(a)=a\otimes 1$ and $\ell(b)=1\otimes b$).  Then given any ring $S$ and any pair of homomorphisms $f:A\to S$ and $g:B\to S$ such that $fi=gj$, then there is a unique homomorphism $h:A\otimes_R B\to S$ such that $hk=f$ and $h\ell=g$.
Now, in this setup, consider the sets $\operatorname{Hom}(A,S)$, $\operatorname{Hom}(B,S)$, and $\operatorname{Hom}(R,S)$.  There is a map $p:\operatorname{Hom}(A,S)\to\operatorname{Hom}(R,S)$ given by composition with $i$, and similarly a map $q:\operatorname{Hom}(B,S)\to\operatorname{Hom}(R,S)$ given by composition with $j$.  We can use these maps to form the fiber product of sets $$\operatorname{Hom}(A,S)\times_{\operatorname{Hom}(R,S)}\operatorname{Hom}(B,S).$$  Explicitly, this is the set of pairs $(f,g)$ where $f:A\to S$, $g:B\to S$, and $fi=gj$.  But by the universal property of $A\otimes_R B$, such pairs are in bijection with homomorphisms $h:A\otimes_R B\to S$.  This gives a natural bijection $$\operatorname{Hom}(A\otimes_R B,S)\cong\operatorname{Hom}(A,S)\times_{\operatorname{Hom}(R,S)}\operatorname{Hom}(B,S).$$  Your second equality is just this natural bijection in the case $S=\mathcal{O}_X(X)$.
A: The pushout in the category of commutative rings is given by tensor products, so the second formula is just the characterization of pushouts in terms of hom-sets.
Similarly, the notation $A \times_B C$ refers to the pullback.
(the maps $A \to B$ and $C \to B$ in the pullback $A \times_B C$ are to be inferred from context, just as the maps $R \to A$ and $R \to B$ are also to be inferred from context when writing $A \otimes_R B$)
A: Note that $$\mathrm{Spec}:\mathbf{Rings}\to \mathbf{Sch}$$ is a contravariant functor.
