Why GMs sometimes don't castle instead they play king f1?


There might be several reasons.
Castling isn't always the best option. In the end-game, when mating threats disappear, the King is a strong piece... about 4 points worth of fighting power (stronger than a Knight but weaker than a Rook). In the end-game, the King belongs in the fight, not hiding in a corner.
So if the Queens are being exchanged off, keeping the King near the center can be the best idea.
Another possible motive is that there might be no safe place for the King to castle. If the two players are attacking on opposite sides, where does the King belong? Right in the path of your opponent's attack? Behind your own Pawn-storm, where your Pawns are moving forward and leaving weak squares behind? In the center? Sometimes f1 might be safer than castling.