I'm reading the proof of Theorem 3.3 in Hartshorn about the existence of fibre product of schemes and I wonder what is the categorical description behind this.
The proof shows that for $X\to S$, $Y\to S$, and an open cover $X=\bigcup X_i$, if $X_i\times _X Y$ exists for every $i$, then these glue together to give the fibre product $X\times_S Y$. Applying this to affine cover $\{X_i\}$ of $X$ and affine cover $\{Y_i\}$ of $Y$ gives the existence of $X\times _S Y$ over an affine scheme $S$.
This seems to suggest that $(\operatorname{colim}_{I} X_i)\times _S Y= \operatorname{colim}_{I} (X_i\times_S Y)$ and $(\operatorname{colim}_{I}X_i)\times_S (\operatorname{colim}_{J}Y_j)=\operatorname{colim}_{I}\operatorname{colim}_{J} (X_i\times_S X_j)$, where $I$, $J$ are the covering sieves corresponding to the cover $\{X_i\}$ and $\{Y_j\}$ in the Zariski topology.
Is this approach right? Can the fibre product for general $X,Y,Z$ be described as a colimit of the fibre product of affine schemes?
Yes, this is correct. The fiber product is a finite limit, and the colimit which writes a scheme as the colimit of its affine open subschemes is a filtered colimit. As filtered colimits commute with finite limits, this proves the claim.
Edit: In response to the comment asking for "a colimit built out of $U_i\times_{S_k} V_j$ for $U_i,V_j,S_k$ open affine covers of $X,Y,S$ respectively", here is how one would do that. Write $f:X\to S$, $g:Y\to S$, $p:X\times_S Y \to X$, and $q:X\times_S Y\to Y$.
Select an affine open cover $\{S_k\}$ of $S$. As the preimages of these open affines in $X$ and $Y$ cover $X$ and $Y$ respectively, we can choose affine open coverings $U_{ik}$ and $V_{jk}$ of $f^{-1}(S_k)$ and $g^{-1}(S_k)$ as $k$ varies. Then $U_{ik}\times_{S_k} V_{jk} = U_{ik}\times_S V_{jk}$ and there's a canonical open immersion of this in to $X\times_S Y$ which identifies it with $p^{-1}(U_{ik})\cap q^{-1}(V_{jk})$. This gives that the collection $U_{ik}\times_{S_k} V_{jk}$ as $i,j,k$ vary forms an affine open cover of $X\times_S Y$.