Let $v_p(x)$ denote the power of a prime $p$ in the factorization of $x$ .
Let $p$ be a prime with $p \mid a$ so it follows that $p \mid b$ (from $a \mid b^2$ ) .
The reverse also holds so $a$ and $b$ must have the same prime factors .
Now take such a prime $p$ .
For every $k \geq 1$ we know that :
$$a^{2k-1} \mid b^{2k}$$ and we can deduce that :
$$v_p(a^{2k-1}) \leq v_p(b^{2k})$$
It's not hard to see that in general $v_p(x^y)=y v_p(x)$ so after rearranging :
$$\frac{v_p(a)}{v_p(b)} \leq \frac{2k}{2k-1}$$
But this holds for every $k$ so taking $k \to \infty$ we get :
$$\frac{v_p(a)}{v_p(b)} \leq 1$$
Using the other relations (of the form $b^{2k} \mid a^{2k+1}$ ) we can deduce that :
$$\frac{v_p(a)}{v_p(b)} \geq 1$$
It follows then that $v_p(a)=v_p(b)$ and this must hold for every prime that divides them . Thus the conclusion $a=b$ must hold .