Deriving the midpoint formula in 3D using the distance formula I want to derive the midpoint of the line segment connecting the points $P_1(x_1,y_1,z_1)$ and $P_2(x_2,y_2,z_2)$ using only the distance formula (since this is all that has been taught to students thus far; if more is needed, please let me know.)
I began by characterizing the midpoint as the point $M(x,y,z)$ such that $|P_1M|=|P_2M|$ which is equivalent to $$(x_1-x)^2+(y_1-y)^2+(z_1-z)^2=(x_2-x)^2+(y_2-y)^2+(z_2-z)^2$$
after squaring both sides. Expanding and cancelling the identical terms from both sides leaves us: $$x_1^2-2x_1x+y_1^2-2y_1y+z_1^2-2z_1z=x_2^2-2x_2x+y_2^2-2y_2y+z_2^2-2z_2z$$
which is equivalent to, after rearranging: $$(x_1^2-x_2^2)+(y_1^2-y_2^2)+(z_1^2-z_2^2)=2x_1x-2x_2x+2y_1y-2y_2y+2z_1z-2z_2z$$
or $$(x_1+x_2)(x_1-x_2)+(y_1+y_2)(y_1-y_2)+(z_1+z_2)(z_1-z_2)=2[x(x_1-x_2)+y(y_1-y_2)+z(z_1-z_2)]$$
Now divide by $2$ on both sides $$\left(\frac{x_1+x_2}{2}\right)(x_1-x_2)+\left(\frac{y_1+y_2}{2}\right)(y_1-y_2)+\left(\frac{z_1+z_2}{2}\right)(z_1-z_2)=x(x_1-x_2)+y(y_1-y_2)+z(z_1-z_2)$$
and subtract all the terms on the right from both sides: $$(x_1-x_2)\left(\frac{x_1+x_2}{2}-x\right)+(y_1-y_2)\left(\frac{y_1+y_2}{2}-y\right)+(z_1-z_2)\left(\frac{z_1+z_2}{2}-z\right)=0$$
Since $(x_1-x_2), (y_1-y_2),$ and $(z_1-z_2)$ are not all necessarily simultaneously zero, we must have that: $$\frac{x_1+x_2}{2}-x=0,\frac{y_1+y_2}{2}-y=0, \frac{z_1+z_2}{2}-z=0 $$ or $$x=\frac{x_1+x_2}{2}$$ $$y=\frac{y_1+y_2}{2}$$ $$z=\frac{z_1+z_2}{2}$$
This $M=\left(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2},\frac{z_1+z_2}{2}\right)$ turns out to be the midpoint formula for the line segment connecting the points $P_1(x_1,y_1,z_1)$ and $P_2(x_2,y_2,z_2)$, but I realized that the original assumption that $|P_1M|=|P_2M|$ is not sufficient to characterize the midpoint of a line segment, although necessary.
For example, one could put points $P_1$ and $P_2$ at the vertices of the base of an isosceles  triangle and point $M$ at the remaining vertex so that $|P_1M|=|P_2M|$, but in this case clearly $M$ isn't the midpoint of the line segment connecting $P_1$ and $P_2$ since it isn't even on this line segment!
So my question is: why was I able to derive the midpoint formula from the necessary but not sufficient condition that $|P_1M|=|P_2M|$?
Edit: All of the above is wrong based on the false assumption I made, pointed out by @Blue in the comments.
I am still trying to prove this midpoint formula using the distance formula, barring vector/line methods from sections ahead.
 A: Going on @Blue's advice, if $M(x,y,z)$ is the midpoint of $P_1$ and $P_2$, then $2|P_1M|=|P_1P_2|$ and $2|P_2M|=|P_1P_2|$.
These two conditions ensure $M$ is both halfway between $P_1$ and $P_2$ and that $M$ is actually on the line segment connecting $P_1$ and $P_2$ (for if not, $M$ must be on two disjoint spheres, except for one point, both of radius $\frac{1}{2}|P_1P_2|$; but this is impossible so $M$ is the single point of intersection between the two spheres on the line segment connecting $P_1$ and $P_2$).
Since $2|P_1M|=|P_1P_2|$ and $2|P_2M|=|P_1P_2|$, we have $2|P_1M|^2+2|P_2M|^2=|P_1P_2|^2$ after squaring both equations and adding them together, which is equivalent to: $$2[(x_1-x)^2+(y_1-y)^2+(z_1-z)^2]+2[(x_2-x)^2+(y_2-y)^2+(z_2-z)^2]=(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2$$ $\iff$ $$x_1^2-4x_1x+2x^2+y_1^2-4y_1y+2y^2+z_1^2-4z_1z+2z^2+x_2^2-4x_2x+2x^2+y_2^2-4y_2y+2y^2+z_2^2-4z_2z+2z^2+2x_1x_2+2y_1y_2+2z_1z_2=0$$
$\iff$ $$(4x^2+x_1^2+x_2^2-4x_1x+2x_1x_2-4x_2x)+(4y^2+y_1^2+y_2^2-4y_1y+2y_1y_2-4y_2y)+(4z^2+z_1^2+z_2^2-4z_1z+2z_1z_2-4z_2z)=0$$
$\iff \text{since $(a+b+c)^2=a^2+b^2+c^2+2ab+2bc+2ac$}$
$$(2x-x_1-x_2)^2+(2y-y_1-y_2)^2+(2z-z_1-z_2)^2=0$$
Finally, for a sum of squares to be zero, each term being squared must be zero $\therefore$ $$2x-x_1-x_2=0\iff x= \frac{x_1+x_2}{2}$$ $$2y-y_1-y_2=0\iff y= \frac{y_1+y_2}{2}$$ $$2z-z_1-z_2=0\iff z= \frac{z_1+z_2}{2}$$
Thus, we've shown the midpoint $M=\left(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2},\frac{z_1+z_2}{2}\right)$.
