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
Suppose you've chosen a mystery topology $\mathcal M$ on $Y$, you don't tell me $\mathcal M$, but you do tell me, for all topological spaces $Z$, which functions $Z\to (Y,\mathcal M)$ are continuous. Then I can determine $\mathcal M$ as the smallest topology $\mathcal T$ on $Y$ such that the identity map from $(Y,\mathcal T)$ to $(Y,\mathcal M)$ is continuous.
(This may seem a cheap trick, but it's essentially the same trick as Yoneda's Lemma.)