Consider the two pairs of similar right triangles (red and blue) in the diagram.
!enter image description here
Writing $C$ for either $C_{e}$ or $C_{i}$, we have $$\frac{|\overline{AC}|}{a} = \frac{|\overline{BC}|}{b} \qquad\to\qquad a\;|\overline{BC}| = b\;|\overline{AC}|$$
Since $A$, $B$, and $C$ are collinear, we can write coordinate-vector equations $$a\;(C-B) = \pm\;b\;(C-A)$$ (where "$\pm$" is "$+$" when $C=C_{e}$, and "$-$" when $C=C_{i}$, reflecting the fact that the vectors $AC$ and $BC$ point in the same, or in opposite, directions), so that $$C = \frac{aB\mp bA}{a\mp b} \qquad\to\qquad C_{e} = \frac{aB - bA}{a - b}\qquad C_{i} = \frac{aB + bA}{a + b}$$
Your formulas follow from substituting the circle centers $A =(x_1, y_1)$ and $B = (x_2,y_2)$ and radii $a=r$ and $b=r^\prime$.