King Safety Trumps Theory
Sometimes openings have certain positional or thematic goals that they wish to accomplish. For example, in the King's Gambit (1.e4 e5 2. f4), one of the primary goals for White is to open the f-file and get play against the square f7 with a rook on f1, a bishop on c4, and perhaps a knight on g5. In the following game, Black plays the Sveshnikov Variation of the Sicilian Defense, a sharp, modern line with its roots in the Boleslavsky and Lasker-Pelikan lines. Black accepts some positional defects (weak d5 square and backward pawn on d6) in return for a stake in the center (e5) and the thematic pawn push, f5. Some of these theoretical ideas come with unspoken caveats, such as "Try to play ...f5 (as long as your king is safely castled or at least your e-pawn is still on the board closing the e-file)". Sometimes players forget about these small details and march ahead blindly towards their thematic goals. They do so at their own peril.
The player of the Black pieces was no beginner, but even he failed to feel the danger to his king. Beginners, of course, succumb to attacks on their kings in the center all the time. They just do not see the benefit of "wasting" a move castling when they could be running around with other pieces (often the Queen) "doing" something. I believe a sense of king safety is more highly developed in players who like to conduct kingside attacks. That is, since they are always reaping the benefits of their opponent's unguarded kings, they have a feel for when their own king is getting near that situation. If you find that you don't have this feel for king safety, then just play it safe and castle as soon as you legally can in each game. Your king will thank you.