Why did the author warn 'Don't do it!' on evaluating the limit of $\lim_{x\to 0} \frac{1-\cos(1-\cos x)}{\sin ^4 x}$ this way?
Second equality is precisely what's wrong. We can't evaluate a limit inside a limit like that. To make it clearer, let's look at another example.
Consider a limit $$\lim\limits_{x\rightarrow0}\frac{x}{x}$$
We have $\lim\limits_{x\rightarrow0}x=0$, but we can't say $$\lim\limits_{x\rightarrow0}\frac{x}{x}=\lim\limits_{x\rightarrow0}\frac{0}{x}$$ Since limit on the LHS is clearly $1$ and on the RHS is clearly $0$. Even if in the case of limit in question the answer was correct (which I didn't bother to check), the way of evaluating this limit is invalid, which is why you should not do that.
While evaluating limit of a complicated expression one should not replace a sub-expression by its limit and continue with further calculations. Thus the step where you replace $(1 - \cos x)/x^{2}$ by $1/2$ is not allowed.
However there are two situations where you can do such replacements:
1) If a sub-expression is connected in additive manner to the rest of the expression then this sub-expression can be replaced by its limit (provided the limit exists). More formally if $\lim_{x \to a}g(x)$ exists and is equal to $L$ then $$\lim_{x \to a}\{f(x) \pm g(x)\} = \lim_{x \to a}f(x) \pm L$$ irrespective of the fact whether $\lim_{x \to a}f(x)$ exists or not.
2) If a sub-expression is connected in multiplicative manner to the rest of the expression then this sub-expression can be replaced by its limit (provided the limit exists and is non-zero). More formally if $\lim_{x \to a}g(x)$ exists and is equal to $L \neq 0$ then $$\lim_{x \to a}f(x)g(x) = L\lim_{x \to a}f(x),\,\lim_{x \to a}\frac{f(x)}{g(x)} = \frac{1}{L}\lim_{x \to a}f(x)$$ irrespective of the fact whether $\lim_{x \to a}f(x)$ exists or not.
These are the only two situations where we can replace the sub-expression ($g(x)$ in the formal versions mentioned above) with its limit ($L$).
The above theorems help us a lot in simplifying the limit evaluation of a complicated expression because in each step we can replace a sub-expression by its limit without worrying about the limit of the remaining part of the expression ($f(x)$ in the formal version) and thereby effectively reducing complicated expressions to simpler ones. Also note that by the use of these rules we can infer the existence (or non-existence) of the limit of a complicated expression (consisting of both $f(x), g(x)$) from the existence (or non-existence) of the limit of a simpler expression ($f(x)$).
Update: OP has raised a very interesting point (via comments) where a sub-expression might not be related to the rest of the expression via arithmetical operations $+,-,\times,/$, but rather through functional symbol. In this case we have the rule that the order of a limit operation and the functional operation can be interchanged provided the function is continuous. More formally if $f$ is continuous then $$\lim_{x \to a}f(g(x)) = f(\lim_{x \to a}g(x))$$ Note that in this case we don't replace a sub-expression by its limit, here the main operation is interchanging the order of applying limit operation and functional operation. The example mentioned in your comment uses the fact that the $\log$ function is continuous wherever it is defined and hence the interchange of limit operation and $\log$ operation is justified.