Here, $f:A \to B$ is a ring homomorphism, thus to any $Q\in\textrm{Spec}( B)$, $f^{-1}(Q)$ is in $\textrm{Spec}( A)$, which induces the map $g: \textrm{Spec}( B) \to \textrm{Spec}( A)$ by Sending $Q$ to $f^{-1}(Q)$.
In the proof of continuity of this map by inverse image of closed subsets criterion, it tried to prove $g^{-1}(V(I))\subset V(IS)$ first, where $I$ is an ideal of $A$. Then it claimed to any $p\in V(I)$, suppose $g(Q)=p$ where $Q\in\textrm{Spec}( B)$,then we can prove $IS \subset Q$, then it follows that $g^{-1}(V(I))\subset V(IS)$.
My question is : for each $p\in V(I)$ why we can find a $Q$ with $g(Q)=p$ ? I think we can always find a $Q$ such that $p\subset g(Q)$, but it's impossible there is always a $Q$ such that $g(Q)=p$, if we can not find such a $Q$, then what's $g^{-1}$(p) (is it $\varnothing$?)? How do we define $g^{-1}(V(I))$ ?
I think that you completely mixed things up in your question. Especially, you seem to make a confusion beteen elements of $A$ and $B$ and (prime) ideals of those rings. By the way, it is really a bad idea in general to note $g$ the map associated to $f$, as $g$ and $f$ generally denote elements of rings... Anyway, here's how a proof would go :
Let $\rho : A \to B$ a morphism of rings (commutative with $1$) and let $\varphi : Y := \textrm{Spec}(B)\to X:=\textrm{Spec}(A)$ the induced map defined by sending a prime ideal $\mathfrak{q}$ of $B$ to the prime ideal $\mathfrak{p}=\rho^{-1}(\mathfrak{q})$ of $A$.
Note that the "$\rho^{-1}$" here nothing to do with an hypothetical inverse of the application $\rho$ : recall that whenever $u : W_1\to W_2$ is a application from the set $W_1$ to the set $W_2$, and $W'_2$ is a subset of $W_2$, one defines the inverse image $u^{-1}(W'_2)$ of $W'_2$ by $u^{-1}(W'_2)=\{w_1\in W_1\;|\;u(w_1)\in W'_2\}$... These are basic set-theoretical notions that you should better be aware of when you are studying $\textrm{Spec}$'s of ring and maps between them... But apparently you are not, as you are mixing everything, anyway.
Now, elements of $X:=\textrm{Spec}(A)$ (resp. $Y:=\textrm{Spec}(B)$) are prime ideals of $A$ (resp. $B$), but when I will want to see an element $x\in X$ (resp. $y\in B$) as a point of the set $X$ (resp. $Y$), I will simply note it $x$ (resp. $y$), but when I want to see it as a prime ideal of $A$ (resp. $B$), I will note it $\mathfrak{p}_x$ (resp. $\mathfrak{q}_y$). So that the equality $\varphi(y) =x$ of points in the set $X$ is equivalent to the equality $\mathfrak{p}_x=\rho^{-1}(\mathfrak{q}_y)$ of prime ideals of $A$.
Take $F$ a closed subset of $X$. By definition of $X$'s topology this means that $F = V(I)$ for some ideal $I$ of $A$, and recall that $V(I)$ is the set of prime ideals (of the ring) containg the ideal $I$. Now $$\varphi^{-1}(V(I)) = \{y\in Y\;|\;\varphi(y)\in F\} = \{\mathfrak{q}\in \textrm{Spec}(B)\;|\;\rho^{-1}(\mathfrak{q})\in V(I)\} = \{\mathfrak{q}\in \textrm{Spec}(B)\;|\;I\subseteq\rho^{-1}(\mathfrak{q})\}$$ and as if $\mathfrak{q}$ is an ideal (you don't even need prime here) of $B$ you have $I\subseteq\rho^{-1}(\mathfrak{q})$ if and only $\rho(I)\subseteq \mathfrak{q}$, and as you have this if and only $\rho(I)B\subseteq \mathfrak{q}$, you get that $$\varphi^{-1}(V(I)) = \{\mathfrak{q}\in \textrm{Spec}(B)\;|\;\rho(I)B\subseteq \mathfrak{q}\} = V(\rho(I)B)$$ by definition of the $V$'s of something. Note that here $\rho(I)B$ is what you call $IB$, and is the ideal of $B$ generated by the image of $I$ by $\rho$.