We assume that OP already understands why $q$ and $\dot{q}$ are independent variables in the Lagrangian $L(q,\dot{q},t)$ (which was the topic of this Phys.SE post), and jump right into the Hamiltonian formalism.
The short answer is that the Hamiltonian $H(q,p,t)$ only depends on phase space variables $q$, $p$, and time $t$. It is not supposed to depend on time derivatives $$\dot{q}, \dot{p}, \ddot{q}, \ddot{p},\ldots .$$
If the Hamiltonian $H(q,p,t)$ does depend on time derivatives, something most likely went wrong during the Legendre transformation from the original Lagrangian formulation.
By the way, for a Lagrangian $L(q,\dot{q},\ddot{q},\ldots,t)$ with higher time derivatives, one may wonder how the corresponding Hamiltonian formulation avoids time derivatives? Well, Ostrogradsky told us how: Introduce more canonical pairs!