That's not how you solve the given equation, not by squaring it and substituting $\sin^2 x + \cos^2 x = 1 $. No.
You solve it by combining the $\sin$ and $\cos$ as one sinusoid of a shifted argument. The procedure is very simple.
Suppose you want to solve
$ a \cos x + b \sin x = c $
where $a,b,c$ are known and the unknown is $x$.
Divide the whole equation by $\sqrt{a^2 + b^2}$, you get
$ \left( \dfrac{ a }{\sqrt{a^2 + b^2}} \right) \cos x + \left( \dfrac{b}{\sqrt{a^2 + b^2} } \right) \sin x = \dfrac{ c }{ \sqrt{a^2 + b^2} } $
Let $\phi$ be the angle whose $\cos \phi = \dfrac{ a }{\sqrt{a^2 + b^2}}$ and whose $\sin \phi = \dfrac{b}{\sqrt{a^2 + b^2} } $ , then we now have
$ \cos \phi \cos x + \sin \phi \sin x = \dfrac{c }{ \sqrt{a^2 + b^2} } $
The left hand side is just $\cos(x - \phi) $, hence
$ \cos(x - \phi) = \dfrac{c}{\sqrt{a^2+b^2}} $
Therefore,
$ x = \phi \pm \cos^{-1} \left( \dfrac{c}{\sqrt{a^2+b^2}} \right) $
These are the two basic solutions. To generalize either solution, just add a multiple of $2 \pi$ to it. So the general solution will be
$ x = \phi + \cos^{-1} \left( \dfrac{c}{\sqrt{a^2+b^2}} \right) + 2 k \pi , k \in \mathbb{Z} $
or
$ x = \phi - \cos^{-1} \left( \dfrac{c}{\sqrt{a^2+b^2}} \right) + 2 k \pi , k \in \mathbb{Z} $