\begin{eqnarray}
d \left(\frac{dx}{dy}\right) &=& \frac{d^2x dy - dx d^2y}{dy^2} \\
&=& \frac{d^2x dy/dx^3 - d^2y/dx^2}{dy^2/dx^3}
\end{eqnarray}
$d^2 x$ is the small change of $dx$. when $x$ is a "input variable", you can set $d^2x = 0$. But when you describe x as function of other variable like x = x(t) and consider t as an input, you have to revive this term.
by setting $d^2x = 0$
\begin{eqnarray}
\frac{d}{dy} \left(\frac{dx}{dy}\right) &=& - \frac{ d^2y/dx^2}{dy^3/dx^3}
\end{eqnarray}
The above consideration about $d^2x$ is illustrated in the following example. The transformation shown below may seem correct but it omits the dependence on $d^2x$ and yield incorrect result.
$$
\frac{d^2y}{dt^2} = \frac{d^2y}{dx^2} \frac{dx^2}{dt^2}
$$
The term $d^2x$ has to be revived in this way.
$$
d^2y = d (dy) = d(y' dx) = dy' dx + y' d^2x
$$
Now using the relation $dy'/dx = y''$
\begin{eqnarray}
\frac{d^2y}{dt^2} &=& y'' \frac{dx^2}{dt^2} + y' \frac{d^2x}{dt^2} \\
\end{eqnarray}
This is a correct transformation. In this example, if you state
$
y'' = \frac{d}{dx} \left(\frac{dy}{dx}\right)
$
and use relation
$
d \left(\frac{dy}{dx}\right) = \frac{d^2y dx - dy d^2x}{dx^2}
$
Then
$$
\frac{d}{dx} \left(\frac{dy}{dx}\right) = \frac{d^2y}{dx^2} - \frac{dy}{dx} \frac{d^2x}{dx^2}
$$
The ambiguity occurs because you can either say
$$
y'' = \frac{d^2 y}{dx^2}
$$
or
$$
y'' = \frac{d^2 y}{dx^2} - \frac{dy}{dx} \frac{d^2x}{dx^2}
$$
To avoid this ambiguity, we should define y'' to refer only to the case where $d^2 x$ is zero.