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.
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.