@lesnar, can I still castle if I have moved my king to avoid this check?
Why is moving King to Kf8 here much better than Kd8?

Well, this thread is definitely past the point where providing an answer would help the OP, but since someone else already necroposted it can't hurt too much.
(Side note...how in the world did Black end up with two pawns on both the f-file and the g-file?)
I think the reason Kf8 is better is because with this move, Black moves the king away from White's army, rather than towards it. White must now reroute if they want to attack the king again, which is not easy and would take a lot of time. Meanwhile, Black can play Re8, and from there the position will likely simplify into an endgame where Black is noticeably better.
Game https://www.chess.com/live/game/6193530657