The domain or sine and cosine functions is always the whole real number line. The range is always [-1,1] for these functions.
All you are doing is using a relationship between cos(2x) and cos(x) which is valid for all values of x that are real numbers (and also most likely for complex numbers as well).
The general proof of the identity can be done through Eulers formula which says e^(iax) = [e^(ix)]^a = cos(ax) + isin(ax) = (cos(x) + isin(x))^a
Once you use this, the only thing left is to realize the quadrants when cos(x) and/or sin(x) is positive or negative. Cos(x) is negative in between branches of (pi/2,3pi/2] and sine is positive in [0,2pi). This is needed since x^2 has both positive and negative solutions and you need to choose the right solution based on the quadrant.