Scenario 1:
$$y=3x+5\tag{1}$$
$$y^{2}=\left(3x+5\right)^{2}\tag{2}$$
When both sides are squared in $(1)$, we lose some information and get $(2)$: the graphs of $(1)$ and $(2)$ aren't the same.
Scenario 2:
$$\sqrt{\left(x-2\right)^{2}+\left(y-3\right)^{2}}=\frac{\left|5x+6y+5\right|}{\sqrt{5^{2}+6^{2}}}\tag{3}$$
$$\left(x-2\right)^{2}+\left(y-3\right)^{2}=\frac{\left(5x+6y+5\right)^{2}}{5^{2}+6^{2}}\tag{4}$$
The graphs of $(3)$ and $(4)$ are exactly the same! When both sides are squared in $(3)$, we get $(4)$, and no information is lost in the process: the two graphs are identical!
Question
- Why is information preserved in scenario 2, i.e. the graphs of $(3)$ & $(4)$ are identical, when information is lost in scenario 1, i.e. the graphs of $(1)$ & $(2)$ aren't identical?
The equation "$A^2=B^2$" is equivalent to "$A=B$ or $A=-B$".
In your first example, both $y = 3x+5$ and $y = -(3x+5)$ are perfectly possible, and $y^2 = (3x+5)^2$ combines those.
In your second example, both $\sqrt{\left(x-2\right)^{2}+\left(y-3\right)^{2}}$ and $\frac{\left|5x+6y+5\right|}{\sqrt{5^{2}+6^{2}}}$ are guaranteed to be positive, so one cannot be the negative of the other; only the $A=B$ case is a possibility to begin with.
In other words: by squaring both sides, we are adding in all points which satisfy $$\sqrt{\left(x-2\right)^{2}+\left(y-3\right)^{2}} = -\frac{\left|5x+6y+5\right|}{\sqrt{5^{2}+6^{2}}}$$ but there are no such points.