It's told in Landau - Classical Mechanics, that in the Hamiltonian method, generalized coordinates $q_j$ and generalized momenta $p_j$ are independent variables of a mechanical system. Anyway, in the case of Lagrangian method only generalized coordinates $q_j$ are independent. In this case generalized velocities are not independent, as they are the derivatives of coordinates.
So, as I understood, in the first method, there are twice more independent variables, than in the second. This fact is used during the variation of action and finding the equations of motion.
My question is, can the number of independent variables of the same system be different in these cases? Besides that, how can the momenta be independent from coordinates, if we have this equation $$p=\frac{\partial L}{\partial \dot{q}}$$
Thank you very much! I hope that my question is clear.