A fairly basic remark to make is that usually we can plainly identify
$$L = T-U$$
where $T$ is the kinetic energy and $U$ is the potential energy, and
$$H = T+U$$
Expressing these quantities for e.g. a Hooke-like spring (or any system where $U\neq 0$) would give you a problem with the sign of $U$ if you simply substitute the expression you find for $\dot{q}(p)$ into the Lagrangian.$^1$ So the Hamiltonian is definitely not just the Lagrangian with $\dot{q}$ expressed in terms of $p$.
More mathematically expressed, the Hamiltonian is defined as the Legendre transform of the Lagrangian. (for some elaboration on the Legendre transformation - particularly in the context of the Lagrangian and Hamiltonian - see my answer here, as well as the other answers to that question)
$^1$ Indeed, the Lagrangian for such a (1D) system would be
$$L(q,\dot{q}[,t]) = \frac{m\dot{q}^2}{2} - \frac{kq^2}{2}$$
for which the canonically conjugate momentum is
$$p = \frac{\partial L}{\partial \dot{q}} = m\dot{q}$$
and therefore
$$\begin{align}
H(q,p[,t]) &= m\dot{q}\cdot\dot{q} - \frac{m\dot{q}^2}{2} + \frac{kq^2}{2} \\
&= \frac{m\dot{q}^2}{2} + \frac{kq^2}{2} \\
H(q,p[,t]) &= \frac{p^2}{2m} + \frac{kq^2}{2}.
\end{align}$$
Just inserting $p$ into the Lagrangian would yield
$$\frac{p^2}{2m} - \frac{kq^2}{2}.$$
Note the sign difference of the second term.