Martijn Pieters identified the difference in his commentin his comment:
The question is more as to why a code block constrains the text; most likely because it uses a scrolling block instead.
Code blocks have a maximum width and height, to prevent long lines and excessively-long code snippets from taking over the page. Content which exceeds these dimensions is hidden (with scrolling allowed to reveal it) via this rule:
pre
{
...
overflow: auto;
...
}
This concerns only the difference in how they overflow; the very different rendering is likely a browser bug.