Wwhy was f5 played here? [FEN &quot;r1b1k2r/3pnpbp/pp2p1p1/2q3B1/3pPP2/1B1P4/PPP1N1PP/R2Q1RK1 b k - 0 1&quot;]

In this position, f5 was played. The reasoning is that Black's king is still in the center, so if White decides to start a kingside attack the king can just to run to safety. But this doesn't make any sense! Black could just castle after the move. Am I missing something?
Black could castle, but that doesn't make the king any safer! White could follow with f5 0-0 Qd2, threatening both f6 and Bh6.
Anyway even if Black could castle that doesn't make f5 a bad move (the only downside being the e5 square becoming a bit weak)