It's possible that this is a duplicate of this question - but if so, I don't know why, and I can't verify whether it's the case. I've got a concrete example, although only dev (and maybe mods) will be able to get at the edit history I suspect, as it was within the first five minutes.
I answered this question including some code - but it didn't come out as code. As far as I could see, there were four spaces at the start of each line - but only some of it came out as code. I eventually fixed it up by replacing those first four visible spaces (with four spaces!) on each line... but it's not at all clear to me what was going on. Note that it caused the code not to be recognized as code in both the preview and the finished post (consistently, fortunately).
I've had this quite a few times, but only in the last 3-6 months. It's really annoying and puzzling - it makes the answerer look like they don't know how to use Markdown, when I think I can safely say I'm aware of how to format code by now...
If someone could check into the edit history, work out what spurious characters were present (assuming they really were) and give suggestions as to how they got there and how they can be avoided (by the system, not the user) that would be very helpful.
vim. It feels likely to be browser-dependent. Are you pasting in code from elsewhere? Writing the entire thing by hand in the window? Placing the spaces by hand yourself or using the editor widget's{}button?