If q/x=p (integer), then q2/x=(q/x)q=pq. So if x is a factor of q then it must be a factor of q2.
However, if x is a factor of q2, it may not be a factor of q. Example: if x=4 and q=6, q2=36, which is divisible by 4, but 6 is not divisible (exactly) by 4.
If x=a2b, where a is an integer, and q2=a2b2 (divisible by x) then q=ab which is not divisible by x (q/x=ab/(a2b)=1/a, which is not an integer).