Fibered product of schemes and global section functor 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.
 A: 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.
A: This is true in great generality, but it is not a formal categorical thing. That the map is an isomorphism is a consequence of the Künneth formula when $X$ and $Y$ are quasi-compact and separated (or just quasi-separated). The Stacks Project tag is https://stacks.math.columbia.edu/tag/0BEC.  
When $Y=\mathrm{Spec}(B)$ is affine and $X$ is quasi-compact and separated, the result is a special case of the compatibility of cohomology of quasi-coherent sheaves with flat base change, and can be proved by tensoring the first few terms of the Čech complex of $\mathscr{O}_X$ relative to a finite affine open covering of $X$ with $B$. All that matters for this argument is that the base is affine and that $B$ is flat over the base.
I would think that the argument given in the Stacks Project becomes simpler if all one wants is the degree zero isomorphism for structure sheaves, but I have not read it carefully enough to say anything precise.
