TITLE: Fibered product of schemes and global section functor
QUESTION [8 upvotes]: Let $X$ and $Y$ be two $k$-schemes ($k$ is a field  ).Suppose that  $\Gamma(Y,\mathcal{O}_Y) =k$. Is the true that $$\Gamma(X \times_{spec(k)}Y, \mathcal{O}_{X \times_{spec(k)}Y}) = \Gamma(X,\mathcal{O}_X) \otimes_{k}  \Gamma(Y,\mathcal{O}_Y) $$
PS: The categorical argument claiming that global section functor preserves colimits is incorrect as explained in one of the answers. In general the above statement is false.

REPLY [3 votes]: The argument you make is not correct.
As you say, the prime spectrum functor $\mathrm{Spec} : \mathbf{CRing}^\mathrm{op} \to \mathbf{Sch}$ and the global section functor $\mathscr{O} : \mathbf{Sch}^\mathrm{op} \to \mathbf{CRing}$ form a contravariant adjunction on the right:
$$ \hom_{\mathbf{CRing}}(R, \mathscr{O}(X)) \cong \hom_{\mathbf{Sch}}(X, \mathrm{Spec}(R) ) $$
which means that both $\mathrm{Spec}$ and $\mathscr{O}$ send colimits to limits. The formal argument is
$$ \hom_{\mathbf{CRing}}(R, \mathscr{O}(\operatorname{colim} X_j))
\cong \hom_{\mathbf{Sch}}(\operatorname{colim} X_j, \mathrm{Spec}(R) ) 
\\ \cong \lim \hom_{\mathbf{Sch}}(X_j, \mathrm{Spec}(R) ) 
\\ \cong \lim \hom_{\mathbf{CRing}}(R, \mathscr{O}(X_j) )
\\ \cong \hom_{\mathbf{CRing}}(R, \lim \mathscr{O}(X_j))  $$
and thus
$$  \mathscr{O}(\operatorname{colim} X_j) \cong \lim \mathscr{O}(X_j) $$
This shows that you have the direction wrong; the assertion you hoped to make was
$$  \mathscr{O}(\operatorname{lim} X_j) \overset{?}{\cong} \operatorname{colim} \mathscr{O}(X_j) $$
However, since $\mathscr{O} \circ \mathrm{Spec}$ is naturally isomorphic to the identity, one thing that does follow for formal reasons is that
$$ \mathscr{O}(\lim \mathrm{Spec}(R_j)) \cong \mathscr{O}(\mathrm{Spec}(\operatorname{colim} R_j)) \cong \operatorname{colim} R_j $$
I.e. the assertion you hoped to make is true for purely formal reasons in the special case that the schemes are affine.