Though I'm not sure I get the logic behind it
In your original code, if there is no data in the receive buffer, Serial.available returns zero.
Zero, as I pointed out, is less than five, so you go ahead and read the five bytes of data that aren't in the buffer.