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.