The surprising thing is not that the second calculation is wrong, but that the first calculation is right.
You shouldn't be using probabilities in the diagram. Instead, you should be counting events. Let's look at the second diagram first. The idea is that we receive $100$ typical emails, so that $30$ are spam and $70$ are desired. Of the $30$ spam emails, $80\%$, or $24$ contain the word "offer" and $6$ do not. Of the $70$ desired emails, $7$ contain the word "offer" and $63$ do not. We have received $31$ emails containing the word "offer" and $24$ of them are spam. We conclude that the probability that an email is spam, given that it contains the word "offer" is $\frac{24}{31}$.
The first problem is peculiar. You are interpreting the phrase "A ball is drawn at random from one of the bags," to me that each of the $17$ balls has an equal probability of being selected. So, if we do this $17$ times, we'll draw $9$ black balls, $3$ from bag II and $6$ from bag $I$ and $$\Pr(I|B)=\frac23$$ if we ignore the denominators in the diagram. How come the book says the answer is $\frac7{12}$? I believe they intend that one of the bags be chosen at random, and then a ball be chosen at random from that bag. Bayes' rule rule gives $$\begin{align}
\Pr(I|B)&=\Pr(B|I)\frac{\Pr(I)}{\Pr(B)}\\
&=\frac{\Pr(B|I)\Pr(I)}{\Pr(I)\Pr(B|I)+\Pr(II)\Pr(B|II)}\\
&=\frac{\frac{6}{10}\cdot\frac12}{\frac12\cdot\frac6{10}+\frac12\cdot\frac37}\\
&=\frac{\frac{6}{10}}{\frac6{10}+\frac37}=\frac{42}{42+30}=\frac7{12}\\
\end{align}$$