So in chinse, the phrase "How are you?" in pinyin is:
nihaoma?
However, when I try to enter it in, I get this:

And the words are broken. Also, the text "so" is:
zheme
Why is this so?
So in chinse, the phrase "How are you?" in pinyin is:
nihaoma?
However, when I try to enter it in, I get this:

And the words are broken. Also, the text "so" is:
zheme
Why is this so?
How your system handles pinyin input largely depends on the system input method. From your pictures I am unable to figure out which one you use. Is it sunpinyin?
Have you considered installing Sogou Pinyin? Sogou has no problem handling the phrases nihaoma and zheme -- I have just checked it on my system.
I have posted instructions on how to install Sogou Pinyin on an Ubuntu machine here
The default pinyin in Ubuntu does have this quirk. I personally use Sun pyinyin or Intelligent pinyin.
You can get both with sudo apt-get install ibus-libpinyin ibus-sunpinyin. Once downloaded, add those in the Settings -> Region & Language -> Input Sources