How to derive the 3D equation of a torus?
Let's select one point $p = (x, y, 0)$. Distance from point p to origin is $\sqrt{x^2 + y^2}$ Distance from point $p$ to the circle with radius $r$ in $xy$-plane is $d = \lvert r - \sqrt{x^2 + y^2} \rvert$. Point $(x, y, z)$ is on the surface of torus if it satisfies $d^2 + z^2 = h^2$ ie. $z^2 = h^2 - \left(r - \sqrt{x^2 + y^2} \right)^2$
First, a minor correction to your formula:
$$z^2 = a^2 - \left(c - \sqrt{x^2 + y^2}\right)^2$$
represents a torus where the distance from the origin to the center of the "tube" is equal to $c$ and the radius of the "tube" is equation to $a$. That being said, it's more natural to ask how this is derived from a circle of the form
$$x^2 + y^2 = 10^2?$$
(Or, in general, the circle $x^2 + y^2 = c^2$.) To see this, recall the parametric form of the circle of radius $c$ (centered at the origin),
$$x(u) = c \cos(u), \quad y(u) = c \sin(u),$$
where $u \in [0, 2\pi)$ is the radial parameter. Let's now think about this circle lying in the $x,y$-plane in $x,y,z$-space, fix some $u = u_0$, and look at a torus with tube radius $a$ centered around this circle.
In each $u = u_0$ slice the picture looks like two circles of radius $a$ centered at distance $\pm c$ from the origin.Let $v \in [0, 2\pi)$ be another radial parameter representing these circles at a given $u_0$. The height of these circles (extending into the $z$-axis) is simply given by
$$z(v) = a \sin(v).$$
Given some $v = v_0$, we also shift our $x$- and $y$-positions from the circle of radius $c$ in the $x,y$-plane by the amount
$$a \cos(v) \quad \text{and} \quad a \cos(v)$$
respectively. This leads to the parametric form of the torus:
$$ \begin{align*} x(u,v) &= \big(c + a \cos(v)\big)\cos(u), \\ y(u,v) &= \big(c + a \cos(v)\big)\sin(u), \\ z(u,v) &= a \sin(v). \end{align*} $$
What's left is verifying that this form is equivalent to the formula above. This is pretty straightforward. Hopefully, the parametric form provides a more natural perspective.