Never quite understood why that's the case. Even if you have Do Not Disturb enabled (even when the phone is unlocked) you still seem to run into this. (Not just in Messages either, in Facebook, and Facebook Messenger as well, even when the notifications within those apps are disabled too).