It's simple geometry, you are calculating the downward angle you need to look relative to the horizontal, from a given elevation, so see the horizon. To lowest order, that angle simply gets added to the angle of rotation of the Earth to make the limb of the Sun reach the horizon.
To calculate that angle, let's measure all distances relative to Earth radius, and say you are at altitude $x$ above the surface. Draw a straight line to the horizon, where that line makes a right angle to the radius of the Earth (it is tangent to the horizon at that point).
So now you have a right triangle with hypotenuse $1+x$, and a side of length $1$, so the angle between the direction you are looking, and the direction to the center of Earth, has a sine of $1/(1+x)$. That means the downward angle we want is however much less that angle is from a right angle. Let's call the downward angle we want $y$, so that $y \ll 1$ if measured in radians, and then what we have from the above is $\sin(\pi/2 - y) = 1/(1+x)$.
Using a trigonometric identity then says $\cos(y) = 1/(1+x)$. But since $x$ and $y$ are $\ll 1$, $\cos(y)$ is close to $1 - y^2/2$ and $1/(1+x)$ is close to $1-x$, so we can say $y$ is close to the $\sqrt{2x}$. That's where the formula comes from, the rest is just unit conversion from radians to degrees and from the radius of the Earth to the altitude in meters.