OP's expression (2) makes sense in distribution theory:
$$\color{blue}{\int_{\mathbb{R}} \!\mathrm{d}x\; \delta(a-x)\; \delta(x-b)\; f(x) ~=~\delta(a-b)\; f(b)}.\tag{A}$$
Proof: If we apply a test function $g\in C^{\infty}_c(\mathbb{R}^2)$ to both sides
$$\begin{align}\iint_{\mathbb{R}^2}\!\mathrm{d}a\;\mathrm{d}b\;g(a,b)\color{blue}{\int_{\mathbb{R}} \!\mathrm{d}x\; \delta(a-x)\; \delta(x-b)\; f(x)}
~=~&\int_{\mathbb{R}} \!\mathrm{d}x\; g(x,x)\; f(x)\cr
~=~&\iint_{\mathbb{R}^2}\!\mathrm{d}a\;\mathrm{d}b\;g(a,b)\;\color{blue}{\delta(a-b)\; f(b)},\tag{B}\end{align}$$
they yield the same result. $\Box$
In other words, the LHS and RHS of eq. (A) is a notation for the same distribution $u\in{\cal D}^{\prime} (\mathbb{R}^2)$ given by $$u[g]~=~\int_{\mathbb{R}} \!\mathrm{d}x\; g(x,x)\; f(x). \tag{C}$$