Let more generally $(X_i)_{i \in I}$ be a family of spaces and $Y$ be another space. By the universal property of the coproduct of spaces, which is the disjoint union in the case of spaces, there is a canonical bijection of sets
$$\textstyle \alpha : C(\coprod_{i \in I} X_i, Y) \to \prod_{i \in I} C(X_i,Y).$$
Explicitly, $\alpha(f)_i = f|_{X_i}$ for $f : \coprod_{i \in I} X_i \to Y$.
Now these sets can be enriched to topological spaces using the compact-open topology and the product topology. I claim that $\alpha$ is a homeomorphism.
First, $\alpha$ is continuous: By the universal property of the product of spaces, it suffices to prove that each $p_i \circ \alpha : C(\coprod_i X_i, Y) \to C(X_i,Y)$ is continuous. This map is induced by pulling back continuous maps with the inclusion $\iota_i : X_i \to \coprod_i X_i$, which is continuous, and hence continuous by the following general lemma:
Lemma. If $g : X \to X'$ is a continuous map, then $g^* : C(X',Y) \to C(X,Y)$, $f \to f \circ g$ is continuous.
Proof. For $K \subseteq X$ compact and $U \subseteq Y$ open we $(g^*)^{-1}(S(K,U)) = S(g(K),U)$ and $g(K) \subseteq X'$ is compact. $\checkmark$
It remains to show that $\alpha$ is open. For this, we use the following easy lemma:
Lemma. Let $f : X \to X'$ be a bijective map between the underlying sets of two spaces. Assume that $X$ has a subbasis $\mathcal{B}$ such that $f(B)$ is open for every $B \in \mathcal{B}$. Then $f$ is open.
Proof. This follows since $f$-images are compatible with unions (this is always the case) and with intersections (since $f$ is bijective; injectivity is not enough since we need empty intersections as well). $\checkmark$
Therefore, it will be sufficient to prove that $\alpha(S(K,U))$ is open in the product, where $K \subseteq \coprod_i X_i$ is compact and $U \subseteq Y$ is open. Let $K_i := K \cap X_i$. This is a subset of $X_i$. Now we compute
$$\begin{align*}
\alpha(S(K,U)) &= \textstyle \bigl\{(f_i)_{i \in I} \in \prod_{i \in I} C(X_i,Y) : f(K) \subseteq U \text{ where } f|_{X_i} = f_i\bigr\} \\
&= \textstyle \bigl\{(f_i)_{i \in I} \in \prod_{i \in I} C(X_i,Y) : \forall i \in I \bigl( f_i(K_i) \subseteq U \bigr)\bigr\} \\
&= \textstyle \prod_{i \in I} S(K_i,U).
\end{align*}$$
By the definition of the topology, this will be an open subset once we show that
- for almost all $i$ we have $S(K_i,U) = C(X_i,Y)$,
- each $K_i \subseteq X_i$ is compact.
To prove this, notice that we have $K = \coprod_{i \in I} K_i$ as sets, but also as spaces, since the sets $K_i \subseteq K$ are open in $K$ are pairwise disjoint. Since $K$ is compact, there is a finite subcover. But this means that almost all $K_i$ are empty, in which case we have $S(K_i,U) = C(X_i,U)$. This proves the first item, and the second item follows from the following general lemma (applied to $X = \coprod_{j \neq i} K_j$ and $Y = K_i$).
Lemma. Let $X,Y$ be two spaces and assume that $X \sqcup Y$ is compact. Then $Y$ is compact as well.
Proof. If $Y = \bigcup_i U_i$ is a union of open subsets $U_i \subseteq Y$, these are also open in $X \sqcup Y$, and we have $X \sqcup Y = X \cup \bigcup_{i \in I} U_i$. Take a finite subcover. This will then yield a finite subcover of the original union. $\checkmark$
Alternative proof (not valid in constructive mathematics). If $Y$ is empty, this is true. If not, take a point $y \in Y$. The identity $Y \to Y$ and the constant map $y : X \to Y$ induce a continuous map $X \sqcup Y \to Y$ by the universal property of the coproduct of spaces. The image is $Y$, hence it's compact. $\checkmark$
This finishes the proof that $\alpha$ is a homeomorphism.
Further remarks about category theory.
The dual version of the first lemma also holds: Every continuous map $Y \to Y'$ induces a continuous map $C(X,Y) \to C(X,Y')$. These two constructions make $(X,Y) \mapsto C(X,Y)$ a functor
$$C(-,-) : \mathbf{Top}^{\mathrm{op}} \times \mathbf{Top} \to \mathbf{Top},$$
and what we did here is to prove that it preserves products in the first variable (notice that products in $\mathbf{Top}^{\mathrm{op}}$ are coproducts in $\mathbf{Top}$). It also does so in the second variable, i.e., the canonical map
$$\textstyle \beta : C(X,\prod_{i \in I} Y_i) \to \prod_{i \in I} C(X,Y_i).$$
is a homeomorphism. This is also easy to prove.
That a functor preserves products, or actually all limits, can often be done by finding a left adjoint functor. Indeed, this is sufficient for a functor to preserve all limits, and by Freyd's adjoint functor theorem the converse holds in many situations. Unfortunately, the left adjoint doesn't exist here when we work with classical topological spaces, but it does exist when one works with a so-called convenient category of topological spaces. More generally, in any cartesian closed category $\mathcal{C}$ for every $Y \in \mathcal{C}$ the functor $[-,Y] : \mathcal{C}^{\mathrm{op}} \to \mathcal{C}$ has a left adjoint $[-,Y] : \mathcal{C} \to \mathcal{C}^{\mathrm{op}}$, even in the enriched sense
$$\bigl[X,[Z,Y]\bigr] \cong \bigl[Z,[X,Y]\bigr],$$
and hence $[-,Y]$ preserves all limits.