The notation here is slightly confusing. $L$ is really just a function of three _a priori_ unrelated variables. Consequently $\frac{\partial L}{\partial \dot{q}}$ is just the partial derivative with respect to the third argument of $L$, which in your case is just $p$. The fact that the third argument is the time derivative of the second argument doesn't come into play at this stage.