Differentiating both sides of an equation
The first of your identities makes some implicit assumptions: it should be read as $$ x^2+f(x)^2=1 $$ where $f$ is some (as yet undetermined) function. If we assume $f$ to be differentiable, then we can differentiate both sides: $$ 2x+2f(x)f'(x)=0 $$ because the assumption is that the function $g$ defined by $g(x)=x^2+f(x)^2$ is constant.
From this we can derive $$ f'(x)=-\frac{x}{f(x)} $$ at least in the points where $f(x)\ne0$, which excludes $x=1$ and $x=-1$ from the domain where $f$ is differentiable.
Thus what you get is that assuming $f$ exists and is differentiable, then, for $x\ne1$ and $x\ne 1$, $f'$ satisfies the above relation.
Why is the relation written in that way? The answer is that often we're given a locus defined by some equation in two variables: it's the set of points $(x,y)$ such that $h(x,y)=0$ and we try finding an explicit form for the locus, that is a relation $y=f(x)$ or $x=g(y)$ , so that $$ h(x,f(x))=0\qquad\text{ or }\qquad h(g(y),y)=0 $$ holds for $x$ in a suitable neighborhood of $x_0$ or $y$ in a suitable neighborhood of $y_0$ where $(x_0,y_0)$ belongs to the locus.
Take for example the folium Cartesii, $x^3+y^3-3xy=0$. If we differentiate with respect to $x$, we get $$ 3x^2+3y^2y'-3y-3xy'=0 $$ which gives $$ y'=\frac{y-x^2}{y^2-x} $$ We're able to find where the derivative is zero by setting $y=x^2$ and plugging in the original equation $$ x^3+x^6-3x^3=0 $$ that is $x=0$ (which can't be used) or $x^3=2$, without even knowing the “explicit form“ $y=f(x)$.
You wrote "$x = 5$"; what does that tell us about $x$? Just that, $x$ equals 5. So in differentiating both sides you must keep that in mind. In other words, $x$ is constant and 5 is constant.
Also, then you can't do
$${d \over dx} x = {d \over dx} 5, \tag{1}$$
since that's equivalent to
$${d \over dx} x = {d \over d5} 5, \tag{2}$$
which already has been pointed out is meaningless.
Though you can do
$${d \over dy} x = {d \over dy} 5 \Leftrightarrow 0 =0;\tag{3}$$
here $y$ is an independent variable over the real numbers.
$x=5$ implies that $x$ doesn't change so it's meaningless to try to take the derivative of it with respect to $x$