Hamiltonian in both cases acts on different objects so it must be different mathematical entity. The trick is
$$
\left<x\right|\hat{H}\left|\Psi(t)\right>=\int dx'\left<x\right|\hat{H}\left|x'\right>\left<x'\right|\left.\Psi(t)\right>=\left<x\right|\hat{H}\left|x\right>\left<x\right|\left.\Psi(t)\right>
$$
Edit: The second equality Holds if hamiltonian is diagonal in position basis. That this is true for standard form hamiltonian can be shown computing matrix elements:
$$
H_{xx'}=\left<x\right|\hat{H}\left|x'\right>=\left<x\right|\left(\frac{\hat{P}^2}{2m}+\hat{V}\right)\left|x'\right>=\left<x\right|\frac{\hat{P}^2}{2m}\left|x'\right>+\left<x\right|\hat{V}\left|x'\right>
$$
The potential term is diagonal if it is defined as function of position operator $
\hat{x}\left|x\right>=x\left|x\right>,
$
which it usually is and this operator is by definition diagonal in position basis.
Less trivial is the momentum operator, which is defined as generator of translation:
$$\left|x+dx\right>=\left(1-i\hat{P}dx/\hbar\right)\left|x\right>$$
From this definition we can compute:
$$
\left<x\right|\hat{P}\left|x'\right>=i\hbar\frac{\left<x\right.\left|x'\right>-\left<x\right.\left|x'-dx''\right>}{dx''}
$$
In the limit $dx''\rightarrow 0$ this shows, that momentum operator is indeed diagonal in position basis, albeit there is distribution on the diagonal instead of ordinary numbers as it was in the case of potential. And since momentum operator is diagonal, so it is its second power and thus also the kinetic term of hamiltonian.
To continue the journey to the standard equation for wave function we can write for momentum
$$
\int dx'\left<x\right|\hat{P}\left|x'\right>\left<x'\right|\left.\Psi(t)\right>=i\hbar\int dx'\frac{\left<x\right.\left|x'\right>-\left<x\right.\left|x'-dx''\right>}{dx''}\left<x'\right|\left.\Psi(t)\right>=i\hbar\int dx'\frac{\delta(x-x')-\delta(x-x'+dx'')}{dx''}\left<x'\right|\left.\Psi(t)\right>=i\hbar\frac{\Psi(x,t)-\Psi(x+dx'',t)}{dx''} \rightarrow -i\hbar\frac{d}{dx}\Psi(x,t)
$$
In similar fashion you can get the second power of momentum operator and then adding the potential function you get standard hamiltonian in wave mechanics.