The real power of $O$ notation is in formulas like this. By systematically applying valid rules of manipulation, we can harness our intuition in a fully rigorous way, without much effort (such as that of dealing with explicit inequalities). (Of course, if we were allergic to $O$ notation, or not sufficiently confident about what manipulations are valid, we could immediately “translate” any $O$-containing expression we encounter into some other notation involving of sets of functions with appropriate quantifiers, but then we'd lose much of the power of $O$ notation.)
Let's look at this example in detail. In this case, we start with the expression $$\frac{2a_0(2N) \ln(2N) + O(2N)}{2a_0N\ln N+O(N)}.$$
(Presumably it has been specified earlier that in this context when we use $O()$ we are thinking of $N \to \infty$, not say $N \to 0$.)
First, to get an intuitive sense, we “THINK BIG”: for large $N$, both the numerator and denominator are dominated by their first terms, i.e. they grow as $2a_0(2N)\ln(2N)$ and $2a_0N\ln N$ respectively. As we see a common $2a_0N$ factor, we can first divide both numerator and denominator by it. Our original expression thus becomes:
$$\frac{2a_0(2N) \ln(2N) + O(2N)}{2a_0N\ln N+O(N)}
\stackrel{(1)}{=} \frac{2\ln(2N) + O(2N)/(2a_0N)}{\ln N + O(N)/(2a_0N)}$$
Here, the manipulation $(1)$ is simply algebra, treating the $O()$ expressions as black-boxes.
Now, in the numerator we have the term $O(2N)/(2a_0N)$. It may be obvious that this is $O(1)$, and you could indeed prove it easily, but you can also use standard manipulation rules that have been proved previously. In this case, for example, we can use a combination of:
which together give $f(n)O(g(n)) = O(f(n)g(n))$. (Recall that with equations containing $O$, all uses of the “$=$” sign are one-way: so we could not directly use $O(f(n)g(n)) = f(n)O(g(n))$ which is $(9.27)$ in the book.) So we can write
$$O(2N)/(2a_0N) = \frac{1}{2a_0N} O(2N) = O\left(\frac{1}{2a_0N}2N\right) = O\left(\frac1{a_0}\right) = O(O(1)) = O(1).$$
(See $(9.25)$ in the book for $O(O(f(n))) = O(f(n))$.) Similarly, for the second term in the denominator, we get $O(N)/(2a_0N) = O(1)$. So our expression becomes:
$$\frac{2\ln(2N) + O(2N)/(2a_0N)}{\ln N + O(N)/(2a_0N)}
\stackrel{(2)}{=} \frac{2\ln(2N) + O(1)}{\ln N + O(1)}$$
using the manipulations above. This is the first equality in the question.
Immediately, we can write the numerator $2\ln(2N) + O(1)$ as $2\ln N + 2\ln 2 + O(1) = 2\ln N + O(1)$, again using manipulations like $c = O(1)$ and $O(1) + O(1) = O(1)$ so $c + O(1) = O(1)$. So our expression is actually:
$$\frac{2\ln(2N) + O(1)}{\ln N + O(1)}
\stackrel{(3)}{=} \frac{2\ln N + O(1)}{\ln N + O(1)}$$
Now, faced with a division, it may be tempting to give up $O$-manipulation and reason with inequalities. But let's have a bit more faith in mindless manipulation. :-)
We can repeat the trick of “dividing”, this time by $\ln n$, to rewrite as
$$\frac{2\ln N + O(1)}{\ln N + O(1)}
\stackrel{(4)}{=} \frac{2 + O(1)/\ln N}{1 + O(1)/\ln N}
\stackrel{(5)}{=} \frac{2 + O\left(\frac{1}{\ln N}\right)}{1 + O\left(\frac{1}{\ln N}\right)}
$$
just as before.
Finally, we can use the rule
$$\frac{1}{1 + O(f(n))} = 1 + O(f(n)) \quad \text{if $f(n) = o(1)$}$$
(I can't find this one in a book right now, but it's obviously useful to have in your toolkit and you can prove it yourself using $\frac{1}{1-x} = 1 + x + x^2 + x^3 + \dots$), to rewrite the expression as
$$
\begin{align}
\frac{2 + O\left(\frac{1}{\ln N}\right)}{1 + O\left(\frac{1}{\ln N}\right)}
&\stackrel{(6)}{=}
\left(2 + O\left(\frac{1}{\ln N}\right)\right)\left(1 + O\left(\frac{1}{\ln N}\right)\right) \\
&\stackrel{(7)}{=} 2 + 2O\left(\frac{1}{\ln N}\right) + O\left(\frac{1}{\ln N}\right) + O\left(\frac{1}{\ln N}\right)O\left(\frac{1}{\ln N}\right) \\
&\stackrel{(8)}{=} 2 + O\left(\frac{1}{\ln N}\right)
\end{align}
$$
where I skipped a few steps in the last equation because surely you get the point by now.
Above, I just wrote everything out in detail for illustration, but in reality, after a bit of practice with valid $O$-manipulations (of course you have to be careful not to do anything that's not justified, but this is similar to when you learned during middle-school algebra not to write $(x+y)^2 = x^2 + y^2$ say), you can become comfortable and don't have to work things out so laboriously: you'll be able to write directly, say,
$$
\frac{2a_0(2N) \ln(2N) + O(2N)}{2a_0N\ln N+O(N)}
= \frac{2\ln N + O(1)}{\ln N+O(1)}
= \frac{2 + O\left(1/\ln N\right)}{1 + O\left(1/\ln N\right)}
= 2 + O\left(\frac{1}{\log N}\right)
$$
pretty much as in the question. There is nothing sloppy or non-rigorous here; you're applying valid rules that have been proved.
Being able to quickly do such calculations for asymptotics is the main benefit of using $O$ notation.