You have to be real careful where the cursor is when you do that or you get the unintended changes you are seeing.
What helps is click more options at the lower right, then click the small wrench icon in the upper right to see the BB codes. That way you can make sure your text is either inside or outside the code tags.