This is one way to think about it:
For any $t ≠ \pm 1$ you can write $t$ as $t = \tfrac{x-3}{x+1}$ or as $t = \tfrac{3+x}{1-x}$ if you set $x = \tfrac{3+t}{1-t}$ or $x = \tfrac{t-3}{t+1}$ respectively (which means that $z ↦ \tfrac{z-3}{z+1}$ and $z ↦ \tfrac{3+z}{1-z}$ are really involutons inverse functions on $ℝ \setminus \{\pm 1\}$). In your solution, the $x$’s of the two fractions are actually different ones, the $t$ stays the same.
So you can translate your solution to
Let $t ≠ \pm 1$.
Write $t = \tfrac{x_1-3}{x_1+1}$ (such $x_1$ exists), then $f(t) + …$
Write $t = \tfrac{3+x_2}{x_2-1}$ (such $x_2$ exists), then $f(\tfrac{3+t}{1-t}) + …$
The conclusions are still true because the functional equations still hold for the $x_i$’s you used to write $t$ (you have to check they are not $\pm 1$, though). Then you can safely add both equalities without contradiction.
Also, it is worth mentioning that the Mobius transformation
$$g \colon ℝ \setminus \{\pm 1\} → ℝ \setminus \{\pm 1\},\, x ↦ \tfrac{x - 3}{x + 1}$$
actually has order $3$, that is $g^3 = \operatorname{id}$, or $g^2 = g^{-1}$, where $g^{-1}$ is actually given by $g^{-1} (x) = \tfrac{3 + x}{1 - x}$. So $g$ and $g^{-1}$ correspond to the fractions you are examining. Then you can think of it that way:
It is given that:
$$f∘g + f∘g^{-1} = \operatorname{id}$$
But then, since $g$ has order $3$, you have.
\begin{align*}
(f + f∘g)∘g &= f∘g + f∘g^2 &=& \operatorname{id}&, \quad \text{and}\\
(f∘g^{-1} + f)∘g^{-1} &= f∘g^{-2} + f∘g^{-1} &=& \operatorname{id}&
\end{align*}
And so, by multiplying with $g$ or $g^{-1}$ from the right you have:
$$f + f∘g = g^{-1}, \quad \text{and} \quad f∘g^{-1} + f = g$$
And so, by adding those and using the functional equation again:
$$g + g^{-1} = (f + f∘g) + (f∘g^{-1} + f) = 2f + \operatorname{id},$$
from which you can derive your result $f = \frac{g + g^{-1} - \operatorname{id}}{2}$.