My question might seem very dumb but here goes.
Your question is one of the most commonly discussed topics in undergraduate mathematics.
It is true that $\frac {dy}{dx}$ is not a quotient. However, it is the limit of a quotient. And for most things we do, limits are actually quite well-behaved. In particular, if $\lim_x f(x)$ and $\lim_x g(x)$ exist, then $\lim_x f(x)g(x) = \lim_x f(x)\lim_x g(x)$.
And this is why the chain-rule works: $\frac{\Delta y}{\Delta x}\frac{\Delta x}{\Delta t} = \frac{\Delta y}{\Delta t}$. Now if $\lim_{\Delta t\to 0}\frac{\Delta x}{\Delta t}$ exists, then it must be that as $\Delta t\to 0, \Delta x\to 0$ as well. Otherwise the fraction would blow up, not converge. So, assuming the two right-side derivatives exist,
$$\begin{align}\frac {dy}{dt} &= \lim_{\Delta t\to 0} \frac{\Delta y}{\Delta t}\\
&= \lim_{\Delta t\to 0}\frac{\Delta y}{\Delta x}\frac{\Delta x}{\Delta t}\\
&= \left(\lim_{\Delta t\to 0}\frac{\Delta y}{\Delta x}\right)\left(\lim_{\Delta t\to 0}\frac{\Delta x}{\Delta t}\right)\\
&=\left(\lim_{\Delta x\to 0}\frac{\Delta y}{\Delta x}\right)\frac{dx}{dt}\\
&=\frac{dy}{dx}\frac{dx}{dt}
\end{align}$$
Now, hopefully you recognize that I've taken a few liberties in that demonstration, skipping over some fiddly details. But that is the point. Because derivatives are limits of quotients, they tend to behave like quotients. It is just the fiddly details that make it wrong to actually think of them as quotients.
If we have $g = \frac{dy}{dx}$, we can also say that $g\,dx = dy$, and this works.
Why does it work?
As stated (and barring the use of some sophisticated higher mathematical concepts), it doesn't work, because it doesn't even exist. There is no such thing as $dx$ or $dy$ by themselves. Instead we can only think of this as a short hand for either $$g\frac{dx}{dt} = \frac{dy}{dt}$$ (i.e., the chain-rule, which I've already explained) or for $$\int \frac{dy}{dx}\,dx = \int dy$$
But what are $\int \frac{dy}{dx}\,dx$ and $\int dy$? They are once again limits:
$$\begin{align}\int \frac{dy}{dx}\,dx &= \lim_{\Delta x \to 0} \sum\frac{\Delta y}{\Delta x}\Delta x\\
&= \lim_{\Delta x \to 0} \sum \Delta y\\
&= \lim_{\Delta y \to 0} \sum \Delta y\\
&= \int dy\end{align}$$
and again we see that if we sweep those fiddly details under the rug and just look at the overall form of the calculation, it is normal quotient behavior that isn't messed up by taking limits.