I noticed that I cannot effectively use/understand the change of variables in different contexts (limits/expressions/etc.). For example, in the proofs of polynomial theorems in Apostol, I came across an exercise a few weeks ago.
First we prove with some algebra that the polynomial $p(x) = f(x + a)$ has the same degree as the polynomial $f(x)$, then that given $f(0) = 0$, $f(x) = xg(x)$, where $g(x)$ has one less degree than $f(x)$. The next part asked to show that if $f(a) = 0$ for some $a$, then $f(x) = (x - a)h(x)$. I DID solve it like this: since we have $f(a) = 0$, then
$f(x - a) = p(x) \Rightarrow p(a) = 0$
Thus, we can use the previous results:
$p(x) = xg(x)$
where $g(x)$ has one less degree than $f(x)$. Then we return to the original scale:
$p(x) = f(x-a) = xg(x) = (x-a)g(x-a)$
And this establishes the result.
However, I do not understand what I am doing here by swapping $x$ for $x-a$, and swapping it back again in the last line. Is it legit? If it is, why? I feel the result is correct, but I cannot comprehend that x is actually the same as x - a when working with the equation. I need some intuitions/theory. I think this is correct because well, it kinda feels right. But is there some rigorous foundation for the variable change? Not the handwaivy "take $y = x^2$" and solve your equation. When is this operation permitted, when not? Is it allowed universally with limits for example?