Given a polar curve such as $r=a^\theta$, we could figue out the corresponding rectangular form by using the fact that $r=\sqrt{x^2+y^2}$ and $\theta=\arctan(\frac{y}{x})$. We would then get the following equation: $$r=a^\theta$$ $$\ln{r}=\theta\ln{a}$$ $$\ln{\sqrt{x^2+y^2}}=(\arctan{\frac{y}{x}})(\ln{a})$$ $$\log_a{\sqrt{x^2+y^2}}=\arctan{\frac{y}{x}}$$ $$\tan{(\log_a{\sqrt{x^2+y^2}})}=\frac{y}{x}$$
However, when this is graphed, https://www.desmos.com/calculator/2bvhqe8ruy, the two equations do not look the same as the rectangular form seems to also show the polar curve rotated $\frac{\pi}{2}$ as well. Could someone please explain why this happens or how I can add some sort of restriction to prevent this from happening. Thanks in advance.
Part of the problem is that the "fact" that "$\color{red}{\theta=\arctan\left(\frac{y}{x}\right)}$" is false. (This is an extremely common mistake, unfortunately.) And that is because $\tan$ is not a one-to-one function, so $\arctan$ is only its partial (or restricted) inverse, only within the interval $\left(-\frac{\pi}{2},\frac{\pi}{2}\right)$. Recall that by definition,
Quick example: the point $(x,y)=(-1,-1)$ lies in the third quadrant, and it's easy to see that its polar angle is $\theta=\frac{5\pi}{4}$. However, $\arctan\left(\frac{y}{x}\right)=\arctan\left(\frac{-1}{-1}\right)=\arctan(1)=\frac{\pi}{4}\neq\frac{5\pi}{4}$, i.e. in this case $\color{green}{\theta\neq\arctan\left(\frac{y}{x}\right)}$. Since the range of $\arctan$ lies only in the fourth and first quadrants, $\arctan$ can't possibly yield the correct value of $\theta$ for points in the second and third quadrants.
Now to your actual question. Another way to rephrase this issue with $\tan$ not being one-to-one: when you apply it, $\tan$ of different values may become the same. In other words: $\alpha=\beta$ implies $\tan\alpha=\tan\beta$; but $\tan\alpha=\tan\beta$ does not imply $\alpha=\beta$. For example, $\tan\frac{5\pi}{4}=\tan\frac{\pi}{4}$ even though $\frac{5\pi}{4}\neq\frac{\pi}{4}$. That's exactly what happened in your work: the last step turned previously unequal quantities into equal ones, thus creating a lot of new (extraneous) solutions that were not solutions before.
Once again: $$\tan{(\log_a{\sqrt{x^2+y^2}})}=\frac{y}{x} \tag{1}$$ does not imply that $$\log_a{\sqrt{x^2+y^2}}=\arctan{\frac{y}{x}}. \tag{2}$$ Many more points satisfy equation $(1)$ than equation $(2)$, which is why the graphs are not the same. For example both $(1,0)$ and $(a^{\pi},0)$ satisfy $(1)$; but only $(1,0)$ satisfies $(2)$, while $(a^{\pi},0)$ doesn't. On the other hand, since $(2)$ implies $(1)$, you see that the graph of $(2)$ is part of the graph of $(1)$.