So if I understand correctly, what you want is a proof of the
Theorem: Let $\left\{ f_i \colon X \to Y_i \mid i \in I\right\}$ a family of maps, where the $Y_i$ are topological spaces, and $X$ is a set. If $\tau_1$ and $\tau_2$ are topologies on $X$ with the property that a map $g \colon (Z,\tau_Z) \to (X,\tau_k)$ is continuous if and only if $f_i \circ g \colon (Z,\tau_Z) \to (Y_i,\tau_{Y_i})$ is continuous for all $i\in I$, then $\tau_1 = \tau_2$.
Proof: Since $\operatorname{id} \colon (X,\tau_k) \to (X,\tau_k)$ is continuous, it follows that $f_i \colon (X,\tau_k) \to (Y_i,\tau_{Y_i})$ is continuous for all $i\in I$, for $k \in \{1,2\}$. Choosing $(X,\tau_2)$ for $(Z,\tau_Z)$ and $g = \operatorname{id}$ in the universal property for $\tau_1$, we find that $g \colon (X,\tau_2) \to (X,\tau_1)$ is continuous, since $f_i \circ g = f_i \colon (X,\tau_2) \to (Y_i,\tau_{Y_i})$ is continuous for all $i\in I$ by the above. Hence $\tau_1 \subset \tau_2$. Swapping the roles, we obtain $\tau_2 \subset \tau_1$, and thus $\tau_1 = \tau_2$.
That shows that the universal property characterises the initial topology uniquely - if it exists.
It remains to see that a topology with the universal property exists. If such a topology exists, it must be the coarsest topology with respect to which all $f_i$ are continuous, hence it must be the topology $\tau$ that has
$$\mathcal{S} = \bigcup_{i\in I}\left\{ f_i^{-1}(U) : U \in \tau_{Y_i}\right\}$$
as a subbasis.
We must see that $\tau$ has the universal property. We note that a map $g \colon (Z,\tau_Z) \to (X,\tau)$ is continuous if and only if $g^{-1}(S)$ is open for all $S \in \mathcal{S}$ (every open set is a union of finite intersections of such sets, hence the preimage of an open set is then a union of finite intersections of open sets, which is open). If $g$ is continuous, then $f_i \circ g$ is a composition of continuous maps, hence continuous, for all $i\in I$. Conversely, if $f_i \circ g$ is continuous for all $i\in I$, and $S\in \mathcal{S}$, say $S = f_{i_0}^{-1}(U_0)$ for an open $U_0 \subset Y_{i_0}$, then
$$g^{-1}(S) = g^{-1}\left(f_{i_0}^{-1}(U_0)\right) = (f_{i_0}\circ g)^{-1}(U_0)$$
is open. Thus $g$ is continuous, and we have seen that $\tau$ has the universal property, so the existence is established.
Now it is easy to see that the topological product of spaces $X_i$ - the Cartesian product $X = \prod\limits_{i\in I} X_i$ endowed with the initial topology $\tau$ with respect to the projections $\pi_i \colon X \to X_i$ - is a product in the category $\mathbf{Top}$.
Given a topological space $(Z,\tau_Z)$ and a family of continuous maps $f_i \colon Z \to X_i$, since the Cartesian product is a product in the category $\mathbf{Ens}$ of sets (you may prefer to call it $\mathbf{Set}$, but I had too Bourbakist teachers for that), there is a unique map $f \colon Z \to X$ with $f_i = \pi_i \circ f$ for all $i\in I$. But, by assumption, $f_i = \pi_i\circ f$ is continuous, hence by the universal property of the product topology, $f$ is indeed continuous, i.e. a morphism in $\mathbf{Ens}$. The uniqueness follows by applying the forgetful functor $\mathbf{Top}\to\mathbf{Ens}$.
Best Answer
First prove that any finite product of connected spaces is connected. This can be done by induction on the number of spaces, and for two connected spaces $X$ and $Y$ we see that $X \times Y$ is connected, by observing that $X \times Y = (\cup_{x \in X} (\{x\} \times Y)) \cup X \times \{y_0\}$, where $y_0 \in Y$ is some fixed point. This is connected because every set $\{x\} \times Y$ is homeomorphic to $Y$ (hence connected) and each of them intersects $X \times \{y_0\}$ (in $(x,y_0)$), which is also connected, as it is homeomorphic to $X$. So the union is connected by standard theorems on unions of connected sets. Now finish the induction. So for every finite set $I$, $\prod_{i \in I} X_i$ is connected.
Now if $I$ is infinite, fix points $p_i \in X_i$ for each $i$, and define $$Y = \{ (x_i) \in \prod_i X_i: \{i \in I: x_i \neq p_i \} \text{ is finite }\}$$
Now for each fixed finite subset $F \subset I$, define $Y_F = \{ (x_i) \in \prod_i X_i: \forall i \notin F: x_i = p_i \}$. By the obvious homeomorphism, $Y_F$ is homeomorphic to $\prod_{i \in F} X_i$, which is connected by the first paragraph. So all $Y_F$ are connected, all contain the point $(p_i)_{i \in I}$ of $\prod_{i \in I} X_i$, and their union (over all finite subsets $F$ of $I$) equals $Y$. So again by standard theorems on the union of connected subsets of a space, $Y$ is a connected subspace of $\prod_{i \in I} X_i$.
Finally note that $Y$ is dense in $\prod_{i \in I} X_i$, because every basic open subset $O$ of the product depends on a finite subset of $I$, in the sense that $O = \prod_{i \in I} U_i$ where all $U_i \subset X_i$ are non-empty open and there is some finite subset $F \subset I$ such that $U_i = X_i$ for all $i \notin F$. Pick $q_i \in U_i$ for $i \in F$ and set $q_i = p_i $ for $i \notin F$. The $(q_i)_{i \in I}$ is in $O \cap Y_F \subset O \cap Y$, so every (basic) open subset of $\prod_{i \in I} X_i$ intersects $Y$.
Now use that the closure of a connected set is connected to conclude that $\prod_{i \in I} X_i$ is connected, also for infinite $I$.