THIS ANSWER GIVES YOU THE FAMILY OF CIRCLES THROUGH TWO GIVEN POINTS.
The way I would work is something like this... if the two points $P_1(x_1,y_1)$ and $P_2(x_2,y_2)$ are on your circle then the line segment $[P_1P_2]$ is a chord. Suppose that the distance $|P_1P_2|=2d$.
Now the perpendicular from the centre of a circle to a chord bisects the chord. We can get the equation of this perpendicular bisector because we have that the midpoint of $[P_1P_2]$ is on it... $((x_1+x_2)/2,(y_1+y_2)/2)$. The slope of the perpendicular bisector, $m$, satisfies $$m\cdot m_{[P_1P_2]}=-1,$$
so is
$$m=-\frac{x_2-x_1}{y_2-y_1},$$
so the perpendicular bisector has equation
$$y=-\frac{x_2-x_1}{y_2-y_1}x+\frac{x_2-x_1}{y_2-y_1}\frac{x_1+x_2}{2}+\frac{y_1+y_2}{2},$$
briefly $k=mh+c$ where $k\sim y$, $h\sim x$ and
$$m=-\frac{x_2-x_1}{y_2-y_1},$$
and
$$c=\frac{x_2-x_1}{y_2-y_1}\frac{x_1+x_2}{2}+\frac{y_1+y_2}{2}$$
Here $h$ is free --- each $h$ gives you a different centre $(h,k)=(h,mh+c)$.
By drawing a picture you will see a RAT triangle with vertices at, say the midpoint of $[P_1P_2]$, the centre $(h,mh+c)$ and $P_1$. Using Pythagoras we have that
$$r^2=d^2+\left(\frac{x_1+x_2}{2}-h\right)^2+\left(\frac{y_1+y_2}{2}-(mh+c)\right)^2$$
So we have that the circles in question are:
$$\{(x-h)^2+(x-(mh+c))^2=r^2:h\in\mathbb{R}\},$$
where each of $m$ and $c$ are functions of $P_1,\,P_2$ and --- once $h$ is chosen --- $r$ is a function of $P_1$, $P_2$ and $h$.
Here is a geometric version, not using a single formula. Start with the points $A$ and $B$ and a line $\ell$ through $A$ (see the figure below).
Construct the perpendicular line to $\ell$ through $A$ (the $\color{red}{\text{red}}$ line). Construct the perpendicular bisectors between $A$ and $B$ (the $\color{green}{\text{green}}$ line, the green dot is the midpoint of $A$ and $B$). The intersection of both constructed lines is the circle's center. The readius is the distance of the center to $A$.
You can translate every step into a formula to solve it numerically if necessary.
Best Answer
Note that center will lie on $x-$axis, therefore let the required equation of circle be of type
$(x-a)^2+y^2=r^2\implies x^2-2ax+a^2+y^2=r^2$
Now it passes through $(2,1) $ and $(2,-1)$, therefore these points will satisfy the equation above
$4-4a+a^2+1=r^2\implies5-4a+a^2=r^2$
Substitute $r^2$ back to get required result
Also note that $a$ here is $x-$ coordinate of center of circle.
Since you want to know that How to show that center will be at $x-$ axis, I will tell you two ways-
--> Take any chord of a circle. If the reflection of any point on it lies on the circle, then only that chord is diameter. Here I used converse of same thing. Since $(2,1)$ and $(2,-1)$ lie on a circle and are reflection of each other on $x-$ axis, therefore $x-$ axis should coincide with one of diameters of circle
--> Let center be $(\alpha,\beta)$ . Since two points lie on circle, therefore their distance from the center should be same which gives $(\alpha-2)^2+(\beta-1)^2=(\alpha-2)^2+(\beta+1)^2$ , solving which gives $\beta=0$ and thus center lies on $x-$ axis.