On page 3 of Atiyah and MacDonald's Commutative algebra book, the following is written.
If $f\colon A\to B$ is a ring homomorphism and $q$ is a prime ideal in $B$, then $f^{-1}(q)$ is a prime ideal in $A$, for $A/f^{-1}(q)$ is isomorphic to a sub-ring of $B/q$ and hence has no zero divisor not equal to zero. But if $n$ is a maximal ideal it is not necessarily true that $f^{-1}(n)$ is maximal in $A$; all we can say for sure is that it is prime.
Why is $A/f^{-1}(q)$ isomorphic to a sub-ring of $B/q$? I intuitively get it, but what's the formal argument? Also, why can't I argue similarly for maximal ideals? What is there in the prime ideal case that does not work in the maximal ideal case? I am aware there is a counter-example but I don't quite understand the essence of it. Can someone help?