I can't understand where the mistake in the following steps is:
$$\int \frac{1}{x}dx = \int x \frac{1}{x^2}dx = -\int x (-\frac{1}{x^2})dx = -\int x(\frac{1}{x})'dx = -x\frac{1}{x} + \int \frac{1}{x}dx = -1 + \int \frac{1}{x}dx$$
So: $$\int \frac{1}{x}dx = \int \frac{1}{x}dx -1$$
Also: Why is it that the integral of this function is $\ln x$? How did people conclude that?
$\int\frac{1}{x}dx$ denotes the set of all antiderivatives of $\frac{1}{x}$. You've shown a function $f$ is such antiderivative iff $f-1$ is too. You need another method to show it's a logarithm. You can note for example that$$\frac{dy}{dx}=\frac1x\implies\frac{dx}{dy}=x\implies x\propto\exp y\implies y=\ln x+C.$$(Due to the discontinuity at $x=0$, $C$ in this context is locally constant. For example, if $x$ is a real variable, we can choose $y-\ln|x|$ to have a $\operatorname{sign}x$-dependent value that's otherwise constant.)