The right question to ask is what $df$ and $dx$ mean in
$$d(x^2-4x)=(2x-4)dx?$$
$\frac{df}{dx}$ is not a fraction but rather a symbol, while $df$ and $dx$ are "entities-symbols" that only make sense in $\frac{df}{dx}$ and not in expressions as above unless one gives them a standalone meaning (see Differential forms)
.
Now for Calculus 2, these two symbols are (usually) not rigorously defined and so the statement
$$d(x^2-4x)=(2x-4)dx$$
makes little to no sense at all. Such non-rigorous manipulations however simplify many concepts in integration:
Integration by Substitution the rigorous way:
Let $g:[a,b]\to \mathbb{R}$ be a differentiable function such as that $g^{\prime}$ is integrable. If $I=g([a,b])$ and $f:I\to \mathbb{R}$ is continuous then
\begin{equation} \int\limits_{a}^{b} (f\circ g)g^{\prime}= \int\limits_{g(a)}^{g(b)} f\end{equation}
To make the above method simpler to state one uses $du$ and $dx$ separately:
Integration by Substitution the non-rigorous way:
Say we want to evaluate,
\begin{equation} \int\limits_{a}^{b} f(g(x))g^{\prime}(x)\, dx\end{equation}
Setting $u=g(x)$ then $du=g^{\prime}(x)dx$ and for $x=a$, $u=g(a)=k$, for $x=b$, $u=g(b)=l$. Thus,
\begin{equation} \int\limits_{a}^{b} (f(g(x)))g^{\prime}(x)\, dx=\int\limits_{k}^{l} f(u)\, du\end{equation}
Simpler than before isn't it?
So to conclude, you are not really doing rigorous math by multipliying by "$dx$", rather you play with the symbols and simplify the results.