I have a homework question that asks me to prove that a given function $f : X \rightarrow Y \times Z$ is continuous if and only if its component functions $f_Y : X \rightarrow Y$ and $f_Z : X \rightarrow Z$ are continuous. I think I solved it, and looking around online, I see that my proof is the same as the one given in various textbooks, so it must be right. But thinking about it further, I'm no longer convinced it is.
My question regards the reverse direction: if the component functions are continuous then $f$ is. My thought was that $f^{-1}(U \times V) = f_Y^{-1}(U) \cap f_Z^{-1}(V)$, so it will be open if $U$ and $V$ are and $f_Y$ and $f_Z$ are continuous, thus showing that $f$ is continuous. This answer seems to be the same answer given in various places online. However, it looks to me that this only works for open sets of the form $U \times V$. The definition of a continuous function (at least the one we're using in class) states that "A function is continuous iff every open set in the range has an open preimage." So why is this proof acceptable? It only considers "rectangular" open sets in the range, not all of them.