It’s not random. The behaviour you are experiencing is due to lines overflowing - so the display can display 20 characters per line over 2 lines, if anything overflows even just one character over that 20 characters, it moves the “cursor” to the next line, and therefore will mess up the layout. The only way to fix this is to clear the display each time you send something to it. The command to do that will depend on your model, I notice you mentioned some codes but you will have to check the command reference manual to check exactly which ones to use.
From my own experience, I have setup a 20x2 line customer display before and I tended to put the description on one line and the price on the other, since the description is usually what overflows. Also with V5, you can use substr
function on a string to limit the number of characters.