The reason for domain restrictions is mainly because we want the "trig functions" to truly be functions in the strict mathematical sense.
That means for every element in the domain the function must produce exactly one function value.
Now one thing about functions is they don't always work equally well in both directions.
The definition of a function says you can get from any point in the domain to a unique point in the range; it says nothing about going from the range to the domain.
As a real-life analogy, there are machines that can turn standing trees into wood chips, but not (yet) any machine that can turn wood chips into a standing tree.
When a function $f$ has a genuine inverse function $f^{-1},$ the inverse really does reverse the effect of the original function:
$f^{-1}(f(x)) = x$ for any $x$ in the domain of $f.$
This works only for a function that is one-to-one, that is, when each value in the range comes from just one unique value in the domain.
As soon as you find even two values in the domain of a function that give the same output value when you use them as input to your function, you know there will not be a genuine inverse function.
The best we can do in cases like that is choose part of the domain of the original function, throw the rest away, and construct a limited "inverse" function that maps the range back to that part of the original function's domain.
So it is reasonable to expect that the domain of the inverse function will be the range of the original function (it certainly cannot be more than that), but it is not reasonable to expect in general that the range of the inverse function will be the domain of the original function. That only works when the original function is one-to-one.
The sine and cosine functions are not one-to-one, so it will not be the case that the range of $\arcsin(y)$ will be the domain of $\sin(x)$
or that you will have $\arccos(\cos(x)) = x$ for every number $x.$
The solution is not to redefine the original function so that it is invertible,
such as by making $\cos(x)$ undefined except when $0 \leq x \leq \pi$
(the range of $\arccos$).
Functions like the sine and cosine are far too useful when we allow them to be many-to-one (multiple input values $x$ that can produce the same output result $f(x)$);
we'd be giving up too much to make them truly invertible.
So we put up with an asymmetric situation: $\cos(x)$ is defined for all $x,$
but $\arccos(y)$ can only "get back" to a small subset of the values for which
$\cos(x)$ is defined, and we choose that subset to be $[0,\pi].$
The first branch point is associated with $f$, and happens at $x=0$. We note that: $$g\circ f(x) =
\begin{cases}
g(2x+1), & \text{if $x≤ 0$} \\
g(x^2), & \text{if $x$ > 0}
\end{cases}$$
Let's just consider each case separately. First, $g(2x+1)$ when $x≤0$. We remark that $x≤0\implies 2x≤0\implies 2x+1≤1$ so we see that $x≤0\implies g(2x+1)=-2x-1$.
Now consider $g(x^2)$ when $x>0$. We see that we hit a branch point at $x=\sqrt 2$. Specifically, $x<\sqrt 2\implies x^2<2$ so $x<\sqrt 2\implies g(x^2)=-x^2$. Of course $x≥\sqrt 2 \implies x^2≥2$ so $x≥\sqrt 2\implies g(x^2)= 5$. Combining all this we see that $$g\circ f(x) =
\begin{cases}
-2x-1, & \text{if $x$ ≤ 0} \\
-x^2, & \text{if $0< x < \sqrt 2$}\\
5 & \text{if $x≥\sqrt 2$}
\end{cases}$$
As a sanity check, we try the special case $x=1$. We note that $g\circ f(1)=g(f(1))=g(1)=-1$ as desired. I advise picking a few other special values just to check.
Best Answer
It means the intersection of the domains (the non-restricted inputs), rather than the intersection of the restrictions!