For context, this is from a quantum mechanics lecture in which we were considering continuous eigenvalues of the position operator. Starting with the position eigenvalue equation, $$\hat{x}\,\phi(x_m, x)=x_m\phi(x_m,x)$$ where $x_m$ is the eigenvalue and $\phi(x_m, x)$ are the continuous eigenfunctions of the position operator $\hat x$. The professor wrote that $\phi(x_m, x)=\delta(x-x_m)$ and stated that this is because the eigenbasis is continuous. But then he wrote the following $$\begin{align}\int_{-\infty}^{\infty}\phi^*(x_m,x)\phi({x_m}',x)\,dx &=\int_{-\infty}^{\infty}\delta(x_m-x)\delta({x_m}'-x)\,dx \tag{1}\\ &=\color{red}{\delta(x_m-{x_m}')}\end{align}$$
I don't understand how the expression in $(1)$ can be equal to the expression in red. I do understand that $$\begin{align}\int_{-\infty}^{\infty}\delta(x_m-x)\phi({x_m}',x)\,dx &=\phi({x_m}',x_m)\tag{2}\\&=\color{#080}{\delta(x_m-{x_m}')}\end{align}$$ since the integral 'sifts' out the only value of $x$ where the argument of the Dirac delta function is zero (at $x_m$). I have applied this sifting property for one Dirac delta function (as in $(2)$).
But I don't understand how this works when there are two Dirac deltas in the integrand, $(1)$.
By my logic, I think it should sift out each value, one at a time, so I think that $(1)$ should be $$\int_{-\infty}^{\infty}\delta(x_m-x)\delta({x_m}'-x)\,dx =\delta(x_m)+\delta({x_m}')$$ where the results of the integration are added, since the values $x_m$ and ${x_m}'$ are sifted out one after the other, depending on which of $x_m$ and ${x_m}'$ are larger (here I assumed ${x_m}'\gt x_m$).
Could someone please derive or explain why equation $(1)$ is true, or give me any hints to help me understand it.