In high school, while teaching definite integration, my maths professor casually remarked that when choosing a variable that you want to substitute viz. in $f\big(g(x)\big)$, if you intend to substitute $g(x)$ as '$t$,' you must be careful that $g(x)$ must compulsorily be a one-one function within the integrating limits, when I asked for the reason he said that it would lead to inconsistencies in the answer, and proceeded. I didn't quite understand the reason behind the same; an explanation would be highly appreciated.
(p.s this is my first post, and I'm not proficient at MathJax so kindly excuse me)
Your teacher is mistaken. Reversals in the direction of the substitution function take care of themselves.
For a simple explanation, allow me to assume $g$ has only a finite number of turn-arounds. So if you are integrating over the interval $[a,b]$, there are points $a = a_0 < a_1 < a_2 < \dots < a_n = b$, such that $g$ is monotonic on each subinterval $[a_{i-1}, a_i]$ for $i = 1, \dots , n$.
To integrate $\int_a^b f(g(t))g'(t)\,dt$ (substitution always involves an integration of this form), first note that
$$\int_a^b f(g(t))g'(t)\,dt = \int_{a_0}^{a_1} f(g(t))g'(t)\,dt + \int_{a_1}^{a_2} f(g(t))g'(t)\,dt + \cdots + \int_{a_{n-1}}^{a_n} f(g(t))g'(t)\,dt$$
Since $g$ is monotone on each of these intervals, you can make the substitution $x = g(t)$, with $dx = g'(t)dt$ To get $$\int_{a_{i-1}}^{a_i} f(g(t))g'(t)\,dt = \int_{g(a_{i-1})}^{g(a_i)} f(x)\,dx$$ So $$\int_a^b f(g(t))g'(t)\,dt = \int_{g(a_0)}^{g(a_1)} f(x)\,dx + \int_{g(a_1)}^{g(a_2)} f(x)\,dx + \cdots + \int_{g(a_{n-1})}^{g(n_i)} f(x)\,dx$$
But $\int_r^sf(x)\,dx + \int_s^tf(x)\,dx = \int_r^tf(x)\,dx$ always, regardless of the order of $r, s,$ and $t$. So $$\int_a^b f(g(t))g'(t)\,dt = \int_{g(a_0)}^{g(a_n)} f(x)\,dx$$ despite $g$ not being monotone overall.
To show this is true more generally requires a dive into the definition of the integral, but it still works.