With respect to contrast on the White background of the application, the Gray background offers low visibility. However, in order for your texts to be legible, the contrast is bumped up again with a Black textColor.
In order for you to text, you need to type the text in the message box and then hit send. So you already know what's present in the text. Hence, it offers you a gray background which doesn't catch the eye so often juxtaposed to the Blue background which is a new text sent by someone else.
This is simply colored differently for the fact that the texts that are incoming to you are more important than the ones you have sent after typing them out.
For the same reason, few messengers also happen to tone down the color of the incoming texts which you have already read and keep the newer texts in a brighter tone.