For example, if we have $\frac{dy}{dx} (\sin(x))$, then we have $\cos(x)$. However, we can not let $x = 2n$, and say that $\frac{dy}{dx}(sin(2n)) = cos(2n)$; we apply the chain rule.
However, in integrals, if we have $\int(t+1)^{-2}dt$, we can let $(t+1) = u$, and then solve $\int (u^{-2})du$ and then achieve the correct answer.
Why is it that substitution works for integrals but not derivatives.
Try the substitution you did in the integral for the derivative, now it does work. try the substitution you did in the derivative for the integral, now it doesn't work. Here is why:
you start with the integral $$ \int (t+1)^{-2} dt$$ and substitute $u = t+1$. that gives you $$ \int u^{-2} dt$$ Notice the dt in the end! you also want this to be in terms of u. To do this, look at the derivative $$\frac{du}{dt} = 1 \iff du = dt$$ So we can just replace $dt$ by $du$. You skipped this step but you were lucky you were correct.
Applying exactly the same reasoning to the derivative will also work. we start with $$\frac{d \sin(x)}{dx}$$ and substitute $x = 2n$. That gives you $$\frac{d \sin(2n)}{dx}$$ Notice the $dx$! We want to write it in terms of $n$. Look at the derivative: $$\frac{dx}{dn} = 2 \iff dx = 2 dn$$ So we can replace $dx$ by $2 dn$ and get $$\frac{d \sin(x)}{dx} = \frac{d \sin(2n)}{2dn} = \frac{2\cos(2n)}{2} = cos(2n) = \cos(x)$$