[proofplan]
We prove three statements: the projections are continuous (their preimages of open sets are basic open sets in the [product topology](/page/Product%20Topology)), a continuous map into the product has continuous components (composition of continuous maps), and the converse holds because preimages of basic open rectangles decompose as intersections of preimages under the components.
[/proofplan]
[step:Prove the projection maps are continuous]
Let $U \subseteq X$ be open. Then $\pi_X^{-1}(U) = U \times Y$, which is a basic [open set](/page/Open%20Set) in the product topology (with the $Y$-factor equal to the full space). Therefore $\pi_X^{-1}(U)$ is open, and $\pi_X$ is continuous. Similarly, for $V \subseteq Y$ open, $\pi_Y^{-1}(V) = X \times V$ is open in the product topology, so $\pi_Y$ is continuous.
[/step]
[step:Prove that continuity of $g: Z \to X \times Y$ implies continuity of the components]
If $g: Z \to X \times Y$ is continuous, then $\pi_X \circ g: Z \to X$ and $\pi_Y \circ g: Z \to Y$ are compositions of continuous maps, hence continuous.
[/step]
[step:Prove that continuity of both components implies continuity of $g: Z \to X \times Y$]
Assume $\pi_X \circ g$ and $\pi_Y \circ g$ are both continuous. It suffices to show $g^{-1}(W)$ is open for every basic open set $W = U \times V$ in the product topology, where $U \subseteq X$ and $V \subseteq Y$ are open. (Every open set in the product topology is a union of such basic open rectangles, and preimages commute with unions.)
We compute:
\begin{align*}
g^{-1}(U \times V) = \{z \in Z : \pi_X(g(z)) \in U \text{ and } \pi_Y(g(z)) \in V\} = (\pi_X \circ g)^{-1}(U) \cap (\pi_Y \circ g)^{-1}(V).
\end{align*}
Since $\pi_X \circ g$ is continuous, $(\pi_X \circ g)^{-1}(U)$ is open in $Z$. Since $\pi_Y \circ g$ is continuous, $(\pi_Y \circ g)^{-1}(V)$ is open in $Z$. The intersection of two open sets is open, so $g^{-1}(U \times V)$ is open in $Z$. Therefore $g$ is continuous.
[guided]
The key idea is that the product topology is generated by "open rectangles" $U \times V$, and the membership condition for a rectangle decomposes into independent conditions on each factor. A point $g(z)$ lies in $U \times V$ if and only if its first coordinate $\pi_X(g(z))$ lies in $U$ and its second coordinate $\pi_Y(g(z))$ lies in $V$. This gives the decomposition
\begin{align*}
g^{-1}(U \times V) = (\pi_X \circ g)^{-1}(U) \cap (\pi_Y \circ g)^{-1}(V).
\end{align*}
Each factor on the right is open by the continuity hypothesis on the components. A finite intersection of open sets is open (this is one of the axioms of a topology), so $g^{-1}(U \times V)$ is open.
Why does it suffice to check basic open sets? Every open set $W$ in the product topology can be written as $W = \bigcup_\alpha (U_\alpha \times V_\alpha)$ for some collection of open rectangles. The preimage respects unions: $g^{-1}(W) = \bigcup_\alpha g^{-1}(U_\alpha \times V_\alpha)$, which is a union of open sets and hence open.
This argument also reveals why the product topology is defined the way it is: it is the coarsest topology on $X \times Y$ making both projections continuous, and the universal property says that this is equivalent to "continuity of a map into the product is determined component-wise."
[/guided]
[/step]