Let $\mathcal{S}$ be a category, fix an object $S \in \mathcal{S}$, and fix two functors $F_i : \mathcal{C}_i \to \mathcal{S}_{/S}$ for $i=1,2$ where $\mathcal{C}_i$ are arbitrary categories.
Suppose $\mathcal{S}$ admits all colimits indexed by $\mathcal{C}_i$ and by $\mathcal{C}_1 \times \mathcal{C}_2$.
Then we have a natural map
$colim_{\mathcal{C}_1 \times \mathcal{C}_2} (F_1 \times_S F_2) \to (colim_{\mathcal{C}_1} F_1) \times_S (colim_{\mathcal{C}_2} F_2). $
Question: Under what conditions on $\mathcal{S}$ and the categories $\mathcal{C}_i$ is this map an equivalence/isomorphism? What if $\mathcal{C}_1 = \mathcal{C}_2$?
I would also be very happy to understand on what kinds of general principles the answer relies. Is this the kind of statement one checks by hand for $\mathcal{S} = Sets$ and when $\mathcal{C}_i$ are small, then assert some Yoneda-type argument to know it's true for categories satisfying certain properties (e.g., compactly generated $\mathcal{S}$)? Or is it simpler than that?