Prove if $a\mid b$ and $b \mid (ap)$ where $p$ is prime, then $b=a$ or $b=ap$ Let $a,b,p \in \mathbb{N}$ such that $a\mid b$ and $b\mid (ap)$ where $p$ is prime. Show that $b=a$ or $b=ap$

So far I know that $b=a(x)$ and $(ap)=b(y)$ where $x,y \in \mathbb{Z}$. Also fro that you can conclude that $a \mid (ap)$ so $ap=a(z)=b(y)$ where $z \in \mathbb{Z}$. Now I don't really see the next steps to use or where the idea that $p$ is prime comes into play. I only have the definition of divide and prime right now also to use.
Hint $\,\ b/a\mid p\,\Rightarrow\,\underbrace{ b/a = 1}_{\large b\ =\ a}\,$ or $\ \underbrace{b/a = p}_{\large b\ =\ ap}$
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$.