"when generating $Y$ from $g(y)$"
This sentence does not tell what $g(\cdot)$ stands for: it could be the cdf, the pdf, the mgf, the characteristic function, the quantile function.
"the inversion method"
This simulation method amounts to
- Generate a uniform $U(0,1)$ variate $U$
- Compute $Y=Q(U)=F^{-1}(U)$
where $F(\cdot)$ is the cdf of $Y$ and $Q(\cdot)$ is its inverse, namely the quantile function.
construct the acceptance-rejection approach for $f$ using samples from
the Uniform distribution in $(−1,1)$
There is a confusion between the inversion method (see above) and the accept-reject method: the latter operates by choosing another distribution with density $f(\cdot)$ to generate from a distribution with density $g(\cdot)$ as follows:
- Generate $X$ with density $f(\cdot)$
- Generate an independent uniform $U(0,1)$ variate $U$
- Set $Y=X$ if $U\le f(X)/g(X)\big/\sup_x \{f(x)/g(x)\}$, else return to 1.
In the current example this means
- Generate $X$ with Cauchy density $f(x)=\sqrt{a}/\pi (a+x^2)^{-1}$
- Generate an independent uniform $U(0,1)$ variate $U$
- Set $Y=X$ if $U\le \mathbb{I}_{(-1,1)}(X)(a+X^2)\big/\sup_{-1\le x\le 1}(a+x^2)$, else return to 1.
Here is an illustration that the method works, based on 10⁶ replications of
x=rcauchy(1)
while(runif(1)>(x^2<1)*(1+x^2)/2) x=rcauchy(1)

I strongly suggest investing in reading the relevant chapter of a
simulation textbook to overcome these confusions.