I think using a specific example supported with pictures can help answer this question, which seems to be a pretty common one over the years on this site. The following comments are specific to $\mathbb R$eal-valued functions of the form: $\mathbb R \to \mathbb R$.
The function we will look at is: $f(\cdot)=\sqrt{1-(\cdot)^2}$.
Taken directly from the solution manual of my book (Spivak's Calculus Ed. 4), here is the argument the author provides to find the so-called 'primitive' of $f(x)=\sqrt{1-x^2}$:
Let $x=\sin(u)$, $dx=\cos(u)du$. The integral becomes
\begin{align} \int\sqrt{1-\sin^2(u)}\cos(u)du&=\int\cos^2(u)du=\int\frac{1+\cos(2u)}{2}du\\&=\frac{u}{2}+\frac{\sin(2u)}{4}\\&=\frac{u}{2}+\frac{\sin(u)\cos(u)}{2}\\&=\frac{\arcsin(x)}{2}+\frac{x\sqrt{1-x^2}}{2}\end{align}
So what exactly does any of this mean? For starters, let us remind ourselves of the definite integral version of the substitution theorem for a continuous function $f$ and continuously differentiable function $g$. Here is how my book (and likely many others) report it:
$$\int_{g(a)}^{g(b)}f(u)du=\int_a^bf(g(x))\cdot g'(x)dx$$
Here is how I, personally, prefer to write it (which is completely equivalent):
$$\int_{g(a)}^{g(b)}f(x)dx=\int_a^b[f\circ g](x)\cdot g'(x)dx \quad(\dagger_1)$$
You will notice I switched out the left-side's dummy variables so that they match the right side. I do this intentionally as I think it detracts from understanding, otherwise. We will use my version going forward.
Importantly, observe that the following form is one eligible instantiation of $(\dagger_1)$:
$$\int_{g\circ g^{-1}(a)}^{g\circ g^{-1}(b)}f(x)dx=\int_{g^{-1}(a)}^{g^{-1}(b)}[f\circ g](x)\cdot g'(x)dx$$, assuming, of course, that the $g$ in question has an inverse $g^{-1}$. Because we are composing inverses, this can be rewritten as:
$$\int_{a}^{b}f(x)dx=\int_{g^{-1}(a)}^{g^{-1}(b)}[f\circ g](x)\cdot g'(x)dx \quad (\dagger_2)$$
Focusing on $(\dagger_1)$ and $(\dagger_2)$, let us now direct our attention to the function $f(\cdot)=\sqrt{1-(\cdot)^2}$.
The $(\dagger_1)$ Perspective
Suppose our integral looked like the following: $\displaystyle \int_{-1}^{\sin(x)}\sqrt{1-t^2}dt$. Graphically, we have:

Well, by $(\dagger_1)$ and imposing that $g(\cdot)=\sin(\cdot)$:
$$\int_{-1}^{\sin(x)}\sqrt{1-t^2}dt=\int_{?}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt \quad (\dagger_3)$$
There is a '$?$' symbol in the lower bound on the right side (and we'll get to that shortly), but, first, let us make one thing clear: $\sqrt{1-t^2} \neq \sqrt{1-\sin^2(t)}\cos(t)$...i.e. these two functions are not the same (go graph them and convince yourself).
Now, time to address the '$?$' symbol. From referencing $(\dagger_1)$, it should be clear why the left side upper bound of integration was $\sin(x)$ and why the right side upper bound of integration was $x$. However, $\sin(x)$ (without any sort of domain restriction) is not an injective function. As such, because we are imposing that $g=\sin$, the left lower bound bound of integration is implicitly saying $g(a)=\sin(a)=-1$. But because a non-restricted $\sin$ is not injective, there is no inverse $g^{-1}$ for us to trivially solve the above expression... i.e. we cannot write $a=g^{-1}(-1)$. We know that $\sin(-\frac{\pi}{2})=-1$...but, more generally, we know that $\sin(-\frac{\pi}{2}-2\pi k)=-1$. For convenience, suppose we choose $k=0$ and $k=1$. Then, adhering to the $(\dagger_1)$ structure, it would seem perfectly legitimate to rewrite $(\dagger_3)$ as both:
$\displaystyle \int_{-1}^{\sin(x)}\sqrt{1-t^2}dt=\int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$
$\displaystyle \int_{-1}^{\sin(x)}\sqrt{1-t^2}dt=\int_{\frac{-5\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$
Indeed, you can see graphically that both of these statements are true (as the red line and dotted blue lines perfectly coincide...note the different lower bound of integration for the red lines):


Let's return to the author's solution manual argument. Recall that the author implicitly argues: $\sqrt{1-\sin^2(t)}\cos(t)=\cos^2(t)$. The only way this is true is if we agree to the assertion that $\sqrt{1-\sin^2(t)}=\cos(t)$. Realize, though, that this is only true if $t \in [-\frac{\pi}{2}+2\pi m, \frac{\pi}{2}+2\pi m]$. If, instead, $t \in [\frac{\pi}{2}+2\pi m, \frac{3\pi}{2}+2\pi m]$, then $\sqrt{1-\sin^2(t)}=-\cos(t)$. From the perspective of the $(\dagger_1)$ representation, this matters (although, as we will see later, this issue is irrelevant for the $(\dagger_2)$ representation).
For convenience, let us focus on $\displaystyle \int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$. Referencing the author's solution, you may be tempted to say $\displaystyle \int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt=\frac{x}{2}+\frac{\sin(x)\cos(x)}{2}-\left[\frac{-\frac{\pi}{2}}{2}+\frac{\sin\left(\frac{-\pi}{2}\right)\cos\left(\frac{-\pi}{2}\right)}{2}\right]$...and this would be just fine assuming we restrict $x$ to $[-\frac{\pi}{2},\frac{\pi}{2}]$. Refer to the below graph, and notice the location where the overlap takes places:

Take my word for it...it's on the interval $[-\frac{\pi}{2},\frac{\pi}{2}]$.
Instead of assuming $\sqrt{1-\sin^2(t)}=\cos(t)$, let's instead assume that $\sqrt{1-\sin^2(t)}=-\cos(t)$. Then you may be tempted to say:
$\displaystyle \int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt=-\frac{x}{2}-\frac{\sin(x)\cos(x)}{2}+\left[\frac{-\frac{\pi}{2}}{2}+\frac{\sin\left(\frac{-\pi}{2}\right)\cos\left(\frac{-\pi}{2}\right)}{2}\right]$...and this would be just fine assuming we restrict $x$ to $[-\frac{3\pi}{2},-\frac{\pi}{2}]$. Refer to the below graph, and notice the location where the overlap takes places:

Take my word for it...it's on the interval $[-\frac{3\pi}{2},-\frac{\pi}{2}]$.
You may be wondering to yourself, "Why is the overlap only taking place at that one isolated interval?" Well, you need to realize that as $x$ varies continuously across the number line, we will experience alternating patterns of when $\sqrt{1-\sin^2(t)}=\cos(t)$ and when $\sqrt{1-\sin^2(t)}=-\cos(t)$, which means, for example if I want to find an expression that is equivalent to $\displaystyle \int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$ for an $x \lt -\frac{3\pi}{2}$, or for an $x \gt \frac{\pi}{2}$, I would have to make a more complicated expression that takes into consideration the alternating $-\cos(t)$ and $\cos(t)$. Consider, for example, the piece-wise function:
$$\int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt=\begin{cases}\frac{x}{2}+\frac{\sin(x)\cos(x)}{2}-\left[\frac{-\frac{\pi}{2}+2\pi m}{2}+\frac{\sin\left(\frac{-\pi}{2}+2 \pi m\right)\cos\left(\frac{-\pi}{2}+2 \pi m\right)}{2}\right] \quad &\text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z \\ -\frac{x}{2}-\frac{\sin(x)\cos(x)}{2}+\left[\frac{-\frac{\pi}{2}+2 \pi m}{2}+\frac{\sin\left(\frac{-\pi}{2}+2 \pi m\right)\cos\left(\frac{-\pi}{2}+2 \pi m\right)}{2}\right]\quad & \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases}$$
And because $\cos(-\frac{\pi}{2}+2 \pi m)=0$, we can rewrite this as:
$$\int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt=\begin{cases}\frac{x}{2}+\frac{\sin(x)\cos(x)}{2}-\left[\frac{-\frac{\pi}{2}+2\pi m}{2}+\right] \quad &\text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z \\ -\frac{x}{2}-\frac{\sin(x)\cos(x)}{2}+\left[\frac{-\frac{\pi}{2}+2 \pi m}{2}\right]\quad & \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases}$$
This is true for all $x \in \mathbb R$. After reading my explanation up to this point, you may be wondering, "So when does $\arcsin$ come into play?". For that, we will now turn our attention to $(\dagger_2)$.
The $(\dagger_2)$ Perspective
Suppose the integral we want to talk about takes the following form: $\displaystyle \int_{\arcsin(a)}^{\arcsin(x)} \sqrt{1-\sin^2(t)}\cos(t)dx$. Before we apply $(\dagger_2)$, let us take note of an important concept. By definition, we know that $\arcsin$ has an inverse in the form of a restricted-domain $\sin$ function, which I will refer to using a capital S...i.e. $\text{Sin}$ is the inverse of $\arcsin$ and, by definition, has the domain $[-\frac{\pi}{2},\frac{\pi}{2}]$. In accordance with this, let us rewrite our integral of interest as follows:
$$\displaystyle \int_{\arcsin(a)}^{\arcsin(x)} \sqrt{1-\text{Sin}^2(t)}\cos(t)dt \quad (\dagger_4)$$.
Note that, for the bounds of integration we are interested in, $\text{Sin}(t)=\sin(t)$ and therefore: $\displaystyle \int_{\arcsin(a)}^{\arcsin(x)} \sqrt{1-\text{Sin}^2(t)}\cos(t)dt=\int_{\arcsin(a)}^{\arcsin(x)} \sqrt{1-\sin^2(t)}\cos(t)dx$.
Letting $f(\cdot)=\sqrt{1-(\cdot)^2}$, $g(\cdot)=\text{Sin}(\cdot)$, and $g'(\cdot)=\cos(\cdot)$ (...the derivative of $\text{Sin}(x)$ on the interval $[-\frac{\pi}{2},\frac{\pi}{2}]$ is just $\cos(x)$...), we see that $(\dagger_4)$ is eligible for a $(\dagger_2)$ application. Thus, we have the relationship:
$$\int_{a}^{x}\sqrt{1-t^2}dt=\int_{\arcsin(a)}^{\arcsin(x)}\sqrt{1-\text{Sin}^2(t)}\cos(t)dt$$
Further simplifying the right side of the expression, and acknowledging that $\text{Image}(\arcsin)=[-\frac{\pi}{2},\frac{\pi}{2}]$, we know that $\sqrt{1-\text{Sin}^2(t)}=\cos(t)$...as opposed to $-\cos(t)$...which means that we can follow the exact argument of author's solution manual up until:
$$\left[\frac{t}{2}+\frac{\text{Sin}(t)\cos(t)}{2}\right] \Bigg |_{\arcsin(a)}^{\arcsin(x)}$$
Remembering that $\cos(t)=\sqrt{1-\text{Sin}^2(t)}$, we can simplify the above expression to:
$$\frac{\arcsin(x)}{2}+\frac{\text{Sin}(\arcsin(x))\sqrt{1-\left(\text{Sin}(\arcsin(x)\right)^2}}{2} - \left[\frac{\arcsin(a)}{2}+\frac{\text{Sin}(\arcsin(a))\sqrt{1-\left(\text{Sin}(\arcsin(a)\right)^2}}{2}\right]$$
Finally, we can simplify to a suspiciously recognizable equation:
$$\frac{\arcsin(x)}{2}+\frac{x\sqrt{1-x^2}}{2} - \left[\frac{\arcsin(a)}{2}+\frac{a\sqrt{1-a^2}}{2}\right] \quad(\dagger_6)$$
That is to say:
\begin{align} \int_{a}^{x}\sqrt{1-t^2}dt&=\int_{\arcsin(a)}^{\arcsin(x)}\sqrt{1-\text{Sin}^2(t)}\cos(t)dt \\ &=\frac{\arcsin(x)}{2}+\frac{x\sqrt{1-x^2}}{2} - \left[\frac{\arcsin(a)}{2}+\frac{a\sqrt{1-a^2}}{2}\right] \end{align}
Concluding Remarks
Our first section revealed that the function $\int_{-\frac{\pi}{2}}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$ could be written as:
$$\begin{cases}\frac{x}{2}+\frac{\sin(x)\cos(x)}{2}-\left[\frac{-\frac{\pi}{2}+2\pi m}{2}+\frac{\sin\left(\frac{-\pi}{2}+2 \pi m\right)\cos\left(\frac{-\pi}{2}+2 \pi m\right)}{2}\right] \quad &\text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z \\ -\frac{x}{2}-\frac{\sin(x)\cos(x)}{2}+\left[\frac{-\frac{\pi}{2}+2 \pi m}{2}+\frac{\sin\left(\frac{-\pi}{2}+2 \pi m\right)\cos\left(\frac{-\pi}{2}+2 \pi m\right)}{2}\right]\quad & \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases}$$
I provided an explicit lower bound value for $G$ to help with some of the visualizations. But, referencing the above piece-wise function (which is specific to the lower bound of integration $-\frac{\pi}{2}$), you should see that I could have just as easily made the lower bound value of the integral an arbitrary constant...let us call it $\gamma$. In this case, we can represent $G(x)=\int_{\gamma}^{x}\sqrt{1-\sin^2(t)}\cos(t)dt$ by the following piece-wise function:
$$\begin{cases}\frac{x}{2}+\frac{\sin(x)\cos(x)}{2}-\left[\frac{\gamma+2\pi m}{2}+\frac{\sin\left(\gamma+2 \pi m\right)\cos\left(\gamma+2 \pi m\right)}{2}\right] \quad &\text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z \\ -\frac{x}{2}-\frac{\sin(x)\cos(x)}{2}+\left[\frac{\gamma+2 \pi m}{2}+\frac{\sin\left(\gamma+2 \pi m\right)\cos\left(\gamma+2 \pi m\right)}{2}\right]\quad & \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases} \quad (*_1)$$
Because $\gamma$ is just a constant, $G'(x)$ evaluates to:
\begin{align}G'(x)&= \begin{cases} \frac{1}{2}+\frac{\cos^2(x)}{2}-\frac{\sin^2(x)}{2} \quad && \text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z\\ -\frac{1}{2}-\frac{\cos^2(x)}{2}+\frac{\sin^2(x)}{2} \quad && \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases} \\&= \begin{cases}\cos^2(x)\quad &&\text{if } x \in [-\frac{\pi}{2}+2 \pi m,\frac{\pi}{2}+2 \pi m] \text{ for any }m \in \mathbb Z \\ -\cos^2(x) \quad && \text{if }x \in [-\frac{3\pi}{2}+2 \pi m,-\frac{\pi}{2}+2\pi m] \text{ for any }m \in \mathbb Z\end{cases}\end{align}
...and this above derivative-based piece-wise function is precisely what $\sqrt{1-\sin^2(x)}\cos(x)$ evaluates to for all $x \in \mathbb R$. Therefore, if someone were to ask what is a primitive of the function $\sqrt{1-\sin^2(x)}\cos(x)$, we can respond with the claim that $(*_1)$ describes a collection of such primitives.
And at long last, we can finally understand what Spivak's solution, first mentioned at the beginning of this post, is attempting to describe. Our section about $(\dagger_2)$'s perspective showed us that the function $F(x)=\int_{a}^{x}\sqrt{1-t^2}dt$ could be described with the following function:
$$\frac{\arcsin(x)}{2}+\frac{x\sqrt{1-x^2}}{2} - \left[\frac{\arcsin(a)}{2}+\frac{a\sqrt{1-a^2}}{2}\right] \quad (*_2)$$
Noting that $a$ is just a constant, if we take the derivative of $F$, then we get:
\begin{align}F'(x)&=\frac{1}{2\sqrt{1-x^2}}+\frac{\sqrt{1-x^2}}{2}+\frac{1}{2}\cdot\frac{x}{2\sqrt{1-x^2}}\cdot(-2x) \\&=\frac{1+(1-x^2)-x^2}{2\sqrt{1-x^2}}\\&=\frac{2(1-x^2)}{2\sqrt{1-x^2}}\\&=\sqrt{1-x^2}\end{align}
What we just demonstrated is that the collection of functions described by $(*_2)$ are all primitives of $\sqrt{1-x^2}$...and this is precisely what Spivak determined using his $u$-substitution approach. The $u$-substitution approach just doesn't give attention to the constant term (i.e. $a=0$ in Spivak's solution).
As you can hopefully see from this post, injectivity / non-injectivity is a non-issue for the substitution theorem of integration. You just need to understand what is being asked.