First you need to know that since $f$ is not necessarily bijective. $f^{-1}(h)$ is not an element, but is the pre-image of $h$ which is a set. So to prove equality of set we need to show that they are subset of each other.
First, let $x\in f^{-1}(h)$, which means $f(x)\in \\{h\\}$.
Therefore, $f(x)=h=f(g)$.
Write $x=g(g^{-1}x)$.
Since $f(g^{-1}x)=(f(g))^{-1}(f(x))=h^{-1}h=1$, $g^{-1}x\in \ker f$.
Hence $x\in g\cdot \ker f$
Converserly, let $x=ga$ where $a\in \ker f$.
Then $f(x)=f(ga)=f(g)f(a)=f(g)=h$ since $f(a)=1$.
We conclude that $x\in f^{-1}(h)$.