For any real or complex numbers $a=b^2$ we have also that $a=(-b)^2$ - and that applies whether or not $a$ is real or complex. So if $a\neq 0$ the equation $x^2=a^2$ will have two solutions $x=\pm a$. We can see this by rewriting the equation as $$(x+a)(x-b)=0$$ which has two roots.
Obviously a function has a single value, and if we want to turn the square root into a function we have to choose a single "principal" value out of the two possible values.
When we work in the real numbers only non-negative integers have a square root and the convention is to choose the positive square root of a positive real number. In the complex numbers every number can have a square root. If $b=a^2e^{2i\theta}$ we have the two solutions $\pm ae^{i\theta}$ to the equation $x^2=b$.
We could, for example choose $- \pi \lt 2\theta \le \pi$ or $0\le 2\theta \lt 2\pi$, and either would give a square root function. In the first case the square root would be the choice with real part $\ge 0$, resolved to the positive imaginary axis for negative reals. In the second case we would choose the solution with non-negative imaginary part, resolved to the positive real solution in the case of positive real numbers. Other choices are also possible.
If you look carefully and think geometrically, you will come to see that this involves tearing the plane down the negative real axis in the first case or the positive real axis in the second case, and that nearby numbers in the plane can have very different square roots. That is not always convenient - so it is sometimes useful to choose one definition over another so that the function is continuous throughout a particular region of interest.
Another way of resolving the issue is to consider the two values of the square root as belonging to two sheets of a single Riemann Surface (with a single value at the origin), which can preserve continuity.
The two values signal the need to take care, but mathematicians have developed tools to do this. As with all such tools it is necessary to learn how to use them and how to recognise the need. For example, in the real numbers the (real) cube root is a function. But when we move to complex numbers there are three possible values for the cube root, and a change of perspective is necessary.
For interest these three values come from the three solutions of the equation $x^3=1$. Obviously $x=1$ is one of these, and writing $x^3-1=(x-1)(x^2+x+1)=0$ we see that the other possible cube roots of $1$ are the solutions of $x^2+x+1=0$.