The problem you are facing with this lies in the fact that the Dirac-delta distribution is not actually a function, it's a type of measure. So you can't treat it formally in the same sense you would treat a function $f:\mathbb{R} \to \mathbb{R}$. When you integrate a function with respect to normal integration
$$
\int f(x) dx
$$
you are implicitly integrating the function $f$ with respect to a type of measure called Lebesgue measure, and Lebesgue measure is for the most part consistent with Riemann integration (they are exactly the same in the case of continuous functions). When you write $\int f(x) \delta(x-a) dx$ it looks like you're doing Riemann integration, but you are in fact not. Instead you are integrating the function $f$ with respect to a different measure.
Another way of thinking about measure, is to see measure as assigning "mass" or importance to certain parts of the real line. In Lebesgue measure, all points are treated equally and mass is assigned to intervals and corresponds to length as we normally would interpret it. For the Dirac measure given by $\delta(x-a)$, one point is considered to contain all of the mass, namely the point $a$.
So when we think of integrating with respect to Dirac measure, it doesn't really make sense to treat $\delta(x-a)$ as a function. Therefore writing $\int \delta(x-a) \delta(a-x)dx$ doesn't really make sense. Another important point is that given a measure defined on a set, we can describe functions as being measurable with respect to that certain measure. It is only when a function is measurable with respect to a certain measure that we are then allowed to integrate it with respect to that measure. It so turns out that $f(x) = \frac{1}{x}$ is not Dirac-measurable, therefore we can't compute the integral $\int f(x) \delta(x)$.