I don't understand this answer, but I've rewritten it to commence with $g(y) = 3$, to avoid ambiguity.
The root of the difficulty is that $x$ appears free in $f(z)$, but we are trying to "capture" it with $g(y)$, which is illegal. When we substitute $g(y)$ into $f(g(y))$, we have a variable clash:
$$ f(g(\color{red} y)) = 3^{5\color{blue}x + 1} $$
The red $y$ is a different variable from the blue $x$.
The original expression [I emboldened] had $x$ bound to the $\mathrm d x$, so by unbinding $\color{lightgreen}{it}$, we have changed the meaning of the expression:
$$ \frac{\mathrm d}{\mathrm d \color{blue} x} f(g(\color{red}y)) \ne \frac{\mathrm d}{\mathrm d \color{red}y} f(g(\color{red}y)) $$
What exactly does it mean to "capture" $x$ with $g(y)$?
Why's this illegal?
What's the original expression?
How was "$x$ bound to the $\mathrm d x$"?
What is "$\color{lightgreen}{it}$"?
How did we unbind "$\color{lightgreen}{it}$"?