Consider $\mathbb{R}$ with the topology induced by euclidean norm and $\mathbb{R^2}$ with the product topology induced by euclidean norm.
Consider $\pi(x,y)=x$
An open set in $\mathbb{R}$ is either $\varnothing, \mathbb{R}$ or an open set $(a,b)$. I can see $\pi^{-1} (\mathbb{R})=\mathbb{R^2}$, and $\pi^{-1}((a,b))$ will be a "rectangle" $(a,b)\times\mathbb{R}$, but is this set open? And for $\pi$ to be continuous I'd need to have for every open set the inverse image is open, but how can I make sense of $\pi^{-1}(\varnothing)$?
the preimage of the empty set is the empty set itself-
And showing that products of open sets are open in the product topology is a standard exercise I encourage you to go for. (Depending on how you define the product topology this might even be trivial)
PS: As already stated in the comments to your question there are more open sets in $\mathbb{R}$ than just the intervals, but you might have learned about a proposition telling you that it's enough to check the preimages of the open intervals. Try to figure out why!