We have to find the complete solution of
$z=px+qy+p^2+q^2$
We take
$f(x,y,z,p,q)=px+qy+p^2+q^2-z$
My doubt is that when we differentiate $f$ with respect to x to find auxiliary equations, we treat p,q and z as independent of x, but they are not.
Why will $\frac{\partial f}{\partial x}$ be $p$ and not $p+x\frac{\partial p}{\partial x}+\frac{\partial q}{\partial x}+2q\frac{\partial q}{\partial x}+2p\frac{\partial p}{\partial x}-p $ ?
You need to disentangle the notation. You are ultimately looking for a solution $z=u(x,y)$. This solution has then derivatives $p=u_x(x,y)$ and $q=u_y(x,y)$.
The solution method that is followed here is to find the characteristic curves via the Lagrange-Charpit equations. These give curves $x(t),y(t)$ with then $z(t)=u(x(t),y(t))$ and $p(t)=u_x(x(t),y(t))$, $q(t)=u_y(x(t),y(t))$.
The PDE $0=f(x,y,u(x,y),u_x, u_y)$ has to be true on all of the surface. Here the total derivatives give $$ 0=f_x+f_zu_x+f_pu_{xx}+f_qu_{xy},\\ 0=f_y+f_zu_y+f_pu_{xy}+f_qu_{yy}.\\ $$ This can then be compared with the dynamic of the characteristic curves (to-be) $$ \dot z = u_x\dot x+u_y\dot y\\ \dot p = u_{xx}\dot x+u_{xy}\dot y\\ \dot q = u_{xy}\dot x+u_{yy}\dot y\\ $$ So if one sets $\dot x=f_p$ and $\dot y=f_q$, then these equations simplify to $$ \dot z=pf_p+qf_q\\ -\dot p=f_x+f_zp\\ -\dot q=f_y+f_zq $$ That this simplification is possible at all justifies the attention given to this construction and naming the resulting curves "characteristic".
The time parameter can be exchanged for another, this results in a common factor $\lambda$ in all time derivatives. Expressing the equality of this factor in all the equation results in the fraction form of the Lagrange-Charpit equations $$ \lambda\, dt=\frac{dx}{f_p}=\frac{dy}{f_q}=\frac{dz}{pf_p+qf_q}=-\frac{dp}{f_x+pf_z}=-\frac{dq}{f_y+qf_z}, $$ with the understanding that the differentials are along the tangent direction of the characteristic curves only.