By definition differential for $f$ function is linear function $g(h)=A\cdot h$, for constant $A$, which represent so called principal part of the change in a function. Formally for $x_0$ point this means $$f(x_0+h)-f(x_0)=g(h)+o(h)=A\cdot h +o(h),h \to 0$$
Proved, that existence of differential is equivalence to function differentiability and $A=f^{'}(x_0)$.
For linear function $g$ is accepted notation $df(x_0) = f^{'}(x_0)dx$, where $dx$ is differential for identity function: $dx(h)=h$. So exact definition should be written:
$$df(x_0)(h) = f^{'}(x_0)dx(h)=f^{'}(x_0) h$$
In brought example $d (\cos x)^2 = -2\cos x \sin x dx$
High order differential, omitting some details, is defined for simple variable as
$$d^n y=y^{(n)}dx^n$$
So for brought example
$d^2 \sin x=-\sin x dx^2$
Note: When I finished first part of question, I found, that you added second one starting with word "Actually". For composition situation is little more difficult and, for example, for composition $z=z[y(x)]$ second differential is
$$d^2z=z^{''}_{yy}dy^2+z^{'}_{y}d^2y$$
Let me write answer to your example little later.
Addition.
As promised:
$$
\begin{array}{}\frac{dy}{dx} = -(n+1)x\left(1-x^2 \right)^{\frac{n-1}{2}} \\
\frac{d^2y}{dx^2} = (n^2-1)x^2\left(1-x^2 \right)^{\frac{n-3}{2}}-(n-1)\left(1-x^2 \right)^{\frac{n-1}{2}} \\
\frac{d^3y}{dx^3} = -(n+1)n^2x^3\left(1-x^2 \right)^{\frac{n-5}{2}}+4nx^3\left(1-x^2 \right)^{\frac{n-5}{2}}-\\ -3(n+1)x^3\left(1-x^2 \right)^{\frac{n-5}{2}}+3nx(n+1)\left(1-x^2 \right)^{\frac{n-3}{2}}-\\ -3x(n+1)\left(1-x^2 \right)^{\frac{n-3}{2}}
\end{array}$$
Sorry, yet, do not see general form.
Meanwhile, if you put $x=\cos kt $, then, whole expression, obviously, become more easy $y(t)=\left(\sin kt\right)^{(n+1)}$, but how it will simplify work for $\frac{d^ny}{dx^n}$, I do not see yet ,
If you would like have $\frac{d^ny}{dt^n}$ then What is the $n$th derivative of $\sin(x)$? help.