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? This is taken from Differential Calculus by Amit M Agarwal:

Evaluate $$\lim_{x\to 0} \frac{1-\cos(1-\cos x)}{\sin ^4 x}$$

The question is quite easy using trigonometric identity viz. $1-\cos x = 2\sin^2\frac{x}{2}$ and then using $\lim_{x\to 0} \frac{\sin x}{x}= 1\,.$ The answer is $\frac{1}{8}\,.$
However, after evaluating the limit, the author cautioned as

Don't do it!
\begin{align}\lim_{x\to 0} \lim_{x\to 0} \frac{1-\cos(1-\cos x)}{\sin ^4 x} & =\lim_{x\to 0} \frac{1-\cos\left(\frac{1-\cos x}{x^2}\cdot x^2\right)}{x^4}\\ &= \lim_{x\to 0}\frac{1-\cos\left(\frac{x^2}{2}\right)}{x^4}\qquad \left(\textrm{As}\, \lim_{x\to 0}\frac{1-\cos x}{x^2}= \frac{1}{2} \right)\\&= \lim_{x\to 0}\frac{2\sin^2 \frac{x^2}{4}}{\frac{x^4}{16}\times 16}\\&= \frac{1}{8}\qquad \textrm{is wrong although the answer may be correct}\,.\end{align}

Where is the 'wrong' in the evaluation?
Edit:


*

*[...] the limit as $x\to 0$ is taken for a subexpression. That's generally invalid.


*We can't evaluate a limit inside a limit like that.


*While evaluating limit of a complicated expression one should not replace a sub-expression by its limit and continue with further calculations.

Now, consider these limits:
$$\bullet \lim_{x \to 4} \log(2x^{3/2}- 3x^{1/2}-1)$$
my book solves this as:
$$\log\; [\lim_{x\to 4} 2 x^{3/2}- \lim_{x\to 4} 3x^{1/2} - \lim_{x\to 4} 1]= 2\log 3$$
Another one:
$$\bullet \lim_{x\to 1} \sin(2x^2- x- 1)$$
This is solved as;
$$\sin\;[\lim_{x\to 1} 2x^2 \lim_{x\to 1} x- \lim_{x\to 1} 1]= \sin 0= 0$$
The following limits are evaluated by first evaluating the limits of sub-expressions. Do these contradict the statement _ you can't take limit of a sub-expression while evaluating the limit of the whole function_?
 A: 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.
A: 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.
