I think the theoretical answer is the "uniqueness" statement in the Fundamental Theorem of Calculus, but I agree it that in the midst of calculations it can seem a bit unbelievable. Still in every example I've seen, the constants end up being a wash and the only danger is changing your mind halfway though about how careful you're trying to be with them.
For instance, if $u=\tan(x)$ then $\arctan(u)=x-n\pi$ for some $n$. (In general this $n$ depends on $x$, yes, but is locally constant; I'll address that later.)
$$\int x\tan(x) d\tan(x) = \int u(\arctan(u)+n\pi)du = \frac{n\pi}{2}\tan^2(x) +\int u\arctan(u)du$$
This looks bad, but let's continue:
\begin{align*}
\int u\arctan(u)du
&= \frac{-u+(1 + u^2)\arctan(u)}{2}+C \\
&= -\frac12\tan(x)+\frac12(1+\tan^2(x))(x-n\pi)+C \\
&= -\frac{n\pi}{2}\tan^2(x) -\frac12\tan(x)+\frac{x}{2}(1+\tan^2(x))+\left(C-\frac{n\pi}{2}\right)\\ ~\\
\int x\tan(x) d\tan(x) &= -\frac12\tan(x)+\frac{x}{2}(1+\tan^2(x))+C'
\end{align*}
So it all plays nicely, at least if we're working in a small enough interval that $n$ is constant. For this particular example we don't have to worry about $n$ changing because the integral diverges if you try to integrate through a discontinuity of the integrand, so everything is undefined anyway. Even if the example were more subtle though, the same calculation would hold, and hence the terms with $n$ would vanish, in each region of continuity.
This issue of constants that look like they might cause problems pops up in Calculus classes in a couple other places that come to mind immediately:
- A bunch of ordinary trigonometry problems where e.g. you get $\sec^2(x)+C$ and the book says gets $\tan^2(x)+C$
- Integration by parts, where $u\int\! v\,dx$ sees the constant get multiplied by a whole function, which looks really concerning.
- Those pesky absolute value bars. You might also be interested in this inverse trig question.