This happens when you paste rich text (HTML). The Typescript playground does this probably to keep the syntax highlighting colors. This will then be converted to Markdown, and since square brackets have a special meaning in Markdown, they are escaped.
Interestingly, if you paste plain text, they are not escaped. And if you copy and paste from your own posting, then it will be pasted as a fenced code block.
Another issue here is that if you paste code into an existing code fence, it will be still escaped. Inside a code fence, everything should be better pasted in raw format only.