It's just element chasing. Maybe if I write it this way:
Firstly note that $f(K)+H=N\implies f^{-1}(f(K)+H)=f^{-1}(N)=M $.
Now we claim that $f^{-1}(f(K)+H) =f^{-1}(H)+K$.
The containment $\supseteq$ is obvious.
Now suppose that $x$ is in the left-hand side. We know that $f(x)=f(k)+h$ for some $k\in K$, $h\in H$.
That implies $f(x-k)=h\in H$, so $x-k\in f^{-1}(H)$. Hence $x\in f^{-1}(H)+K$. The containment $\subseteq$ has been proven.