Given a Lagrangian ##L=L(q^j,\dot{q}^j)## by definition the canonical momenta are defined as
$$p_j=\frac{\partial L}{\partial \dot{q}^j}.$$
The equations of motion follow from the stationarity of the action (Hamilton's principle)
$$S[q]=\int_{t_1}^{t_2} \mathrm{d} t L(q^j,\dot{q}^j)$$
under variations of the ##q^j##, with the boundary values fixed, i.e., ##\delta q^j(t_1)=\delta q^j(t_2)##, leading to the Euler-Lagrange equations,
$$\frac{\partial L}{\partial q^j} - \frac{\mathrm{d}}{\mathrm{d} t} \frac{\partial L}{\partial \dot{q}^j}=0.$$
Now if ##L## is not explicitly time dependent, it's easy to show that
$$E=p_j \dot{q}^j-L=\text{const}$$
along any solution of the Euler-Lagrange equations (just try to prove it yourself, by showing ##\dot{E}=0##).
Here, however, the story nearly only begins! The most beautiful way to express classical mechanics (and a lot more physics, including field theories by appropriately generlizing Hamilton's principles to that case) is in terms of the Hamilton formulation, i.e., you define the Hamilton function, which is by definition a function of the ##q^j## and the ##p_j## by
$$H(q^j,p_j)=\dot{q}^j p_j - L.$$
The point is that you have to substitute for the ##\dot{q}^j## the corresponding expressions in terms of ##p_j## and ##q^j##.
Then you can show that you get the equations of motion by an extended variational principle, i.e., using the action
$$A[q^j,p_j]=\int_{t_1}^{t_2} \mathrm{d} t [p_j \dot{q}^j-H],$$
and making it stationary under variations of the ##q^j## with fixed boundary values (as in the Lagrangian version of the Hamilton principle) and of the ##p_j## without constraints. Then you get the equations of motion in terms of the Hamilton canonical equations:
$$\dot{p}_j=-\frac{\partial H}{\partial q^j}, \quad \dot{q}^j=\frac{\partial H}{\partial p_j},$$
and these are equivalent to the Euler-Lagrange equations from the Lagrangian form of the Hamilton principle.
The great advantage of the Hamilton formulation is that you can introduce Poisson brackets, leading to a reach mathematical toolbox, involving Lie algebras (and Lie groups) to formulate symmetries in the most elegant way. Last but not least it's a way to formulate classical mechanics that is very close to quantum theory, and you can use it as a heuristic tool to formulate quantum theory ("canonical quantization").