I found something I haven't noticed before while solving the following problem:
$$\left(9a^2b^\frac12c^\frac13\right)^\frac12\text{ }\color{red}{(b,c\ge0)}$$
I said, okay we can use the property $(a^m)^n=a^{mn}$, and then we will have $$\left(9a^2b^\frac12c^\frac13\right)^\frac12=9^\frac12a^\color{red}{1}b^\frac14c^\frac16=3a\sqrt[12]{b^3c^2}$$ That was my final answer. Then I checked the answer in the book and it was $3\color{red}{|a|}\sqrt[12]{b^3c^2}.$ And e.g. $[(-2)^2]^\frac12\ne-2$ indeed. Then my question is for what values does $(a^m)^n=a^{mn}$ hold? How should this property look in our case? Thank you!
Don't use the laws of exponents when the base is negative:
But when $a<0$ and $n,m$ are not necessarily integers bad things can happen like you've shown. The way you should treat your exercise is to note that since $a$ may be negative then when you simplify $(a^2)^{\frac{1}{2}}$ you do not use the laws of exponentiation to reach $a$ but instead write this as $\sqrt{a^2}$ which equals $|a|$ for any $a$. [The law $(a^2)^{\frac{1}{2}}=\sqrt{a^2}$ remains correct because $a^2\geq 0$.]
In general you need to be very careful with the exponential functions when the base is negative, and most commonly one defines the function $f(x)=a^x$ only for $a>0$ (unless one is considering only integer exponents, then negative bases are fine).
For instance what is $(-1)^{\frac{1}{2}}$? Surely it is undefined, but on the other hand blindly using the laws of exponents we get $\frac{1}{2}=\frac{2}{4}$ so it must equal $\sqrt[4]{(-1)^{2}}=1$, an absurdity. Even worse: $$-1=\sqrt[3]{-1}=(-1)^{\frac{1}{3}}=(-1)^{\frac{2}{6}}=\sqrt[6]{1}=1$$ We proved $1=-1$ and we didn't even use any of the laws of exponentiation other than $a^{\frac{b}{c}}=\sqrt[c]{a^b}$. All of this shows one should be very careful with negative bases.