By the fundamental theorem of arithmetic, every positive rational number $x$ can be uniquely written as
$$x = \prod\limits_p p^{\textrm{ord}_p x}$$
where $p$ runs through all the prime numbers, $\textrm{ord}_p x$ is an integer, and $\textrm{ord}_p x = 0$ for all but finitely many $p$. The number $x$ is an integer if and only if none of the numbers $\textrm{ord}_p x$ are negative.
Let $q$ be a particular prime number, and suppose that $a$ divides $b$ and $b$ divides $qa$. This means that $b/a$ and $qa/b$ are both integers. Thus all the exponents in
$$b/a = \prod\limits_p p^{\textrm{ord}_p b - \textrm{ord}_p a}$$
are nonnegative, and the same for
$$aq/b = \prod\limits_p p^{\textrm{ord}_p a + \textrm{ord}_p q - \textrm{ord}_p b}$$
Since $\textrm{ord}_p q$ is $0$ or $1$, depending on whether $p \neq q$ or $p = q$, this tells us that $\textrm{ord}_p b = \textrm{ord}_p a$ for all $p \neq q$, and $\textrm{ord}_q b - \textrm{ord}_q a$ and $\textrm{ord}_q a - \textrm{ord}_q b + 1$ are both nonnegative.
The only way this last thing can happen is if either $\textrm{ord}_q a = \textrm{ord}_q b$ or $\textrm{ord}_q a = \textrm{ord}_q b - 1$. In other words, either $a = b$ or $aq = b$.