Munkres is proving the following statement:
"Let $f: \ X \ \rightarrow \ Y$ be continuous. If $f(X) \ \subset \ Z \ \subset \ Y$, we show that the function $g: \ X \ \rightarrow \ Z$ obtained from $f$ is continuous."
He proves it the following way:
"Let $B$ be open in $Z$. Then $B \ = \ U \ \cap \ Z$ for some open set $U$ of $Y$. Because $Z$ contains the entire image set $f(X)$, then $f^{-1}(U) \ = \ g^{-1}(B)$. This then implies that $g$ is continuous.
Now, I understand most of this proof, however, I don't understand the how Munkres arrived at $f^{-1}(U) \ = \ g^{-1}(B)$. We get that $g^{-1}(U \ \cap \ Z) \ = \ g^{-1}(U) \ \cap \ g^{-1}(Z) \ = \ g^{-1}(U) \ \cap \ X \ = \ g^{-1}(U)$, but how can we instantly equate this to $f^{-1}(U)$? If we chose a $U$ that is not in $Z$, how would $f^{-1}(U) \ = \ g^{-1}(U)$?