Given $X$ and $Y$ topological spaces, I need to
prove that the product topology on $X \times Y$ is the finest one such that for any topological space $Z$, and continuous functions $f: Z \to X$ and $g: Z \to Y$, the function $(f\times g): Z\to X\times Y$ is continuous.
What I did was to write $f=\pi_1\circ(f\times g)$ and $g=\pi_2\circ(f\times g)$.
Then take an open set $U$ in the topology of X. Since $f$ is continuous,
\begin{equation} f^{-1}(U)=(f\times g)^{-1}( \pi_1^{-1}(U))=(f\times g)^{-1}(U\times Y) \end{equation}
is an open set in $Z$. Similarly, we get that $(f\times g)^{-1}(X\times V)$ is also an open set in Z, where $V$ is open in $Y$.
This means that we need the preimage of all sets of these forms to be open in $Z$, but $\{X\times V\} \cup \{U \times Y\}$ are a subbase for the product topology.
Is my reasoning correct? How do I prove there is no finest topology that works?
Your reasoning is correct. One suggestion for the notation, though: You should write $$ (f\times g)^{-1}(\pi_1^{-1}(U)) $$ instead of $$ \color{red}{(f\times g)^{-1}\circ \pi_1^{-1}(U)} $$ since you are not composing any inverse functions here. Your notation would only work if $(f \times g)$ and $\pi_1$ were bijective function and thus had inverse functions which you could compose.
Here is an approach for the other part of the problem: Let $(X \times Y, \tau_p)$ be the space $X \times Y$ with the product topology. Assume $(X \times Y, \tau_*)$ is any space on the Cartesian product with the property that for any continuous functions $f: Z \to X$ and $g: Z \to Y$, the function $(f \times g): Z \to (X \times Y, \tau_*)$ is continuous. You want to show that the product topology $\tau_p$ is finer than the topology $\tau_*$, or in terms of functions, that the identity function $\text{id}: (X \times Y, \tau_p) \to (X \times Y, \tau_*)$ is continuous. Can you find a way to use the property of $\tau_*$ to obtain such a function?