Ah I know of this one and yes it's very annoying. But I can explain the behavior for you, though it won't be any less random-seeming in my experience.
Depending on where you stop your selection with the cursor, Teams will think you either only have text selected, or you've selected the message itself. The latter is what adds the message data to your clipboard, and the border between text and message selection is impossible to tell. On MacOS I can _barely_ see some text highlighting when I grab the message, but it's not always clear.
Edit: additional complaint
Teams is bad with text in general. It inserts so many random new lines and hidden characters for cosmetic purposes only, and unless you've dealt with the issue before, you have no way of knowing why the powershell one-liner you copied from teams has a bunch of ????????? at random places like code blocks.