Expanding on @Did's comment (with what I believe is my understanding).
In the equation, the symbol $q$ is being reused as both '$q$ the variable' and '$q(p, q)$ the implicit function (from the relation $a=pq$) returning the value of $q$ given the values of $p$ and $q$'. The value of $q$ given $p$ and $q$ is trivially just $q$, in other words $q(p, q)$ can be thought of as $q(p', q') = f(p', q')$ (dashes added to differentiate the function from its parameters), with:
$$f(p', q') = q'$$
Another way to think of it could be beginning with the more intuitive function $q(p,a)$, which returns the value of $q$ given the values of $p$ and $a$:
$$q(p, a) = \frac{a}{p}$$
And substituting $a$ for $a(p,q)$, where $a(p,q) = pq$:
$$q(p, a(p, q)) = \frac{a(p, q)}{p} = \frac{pq}{p}=q$$
Noticing that $q(p, a(p, q))$ is now just a function of $p$ and $q$ so redefining $q$ yet again:
$$q(p,q)=q(p,a(p,q))=q$$
So taking the partial derivative of $q(p,q)$ (the function) with respect to $p$, while keeping $q$ (the variable) constant, yields $0$.
($q$ can be kept constant as $a$ is free to vary)
Thought I'd answer my own question providing my understanding along with what's been said in the comments to possibly help provide a clearer explanation for future readers.