It does not make sense to judge any piece of code that does not meet "highest standard" to be a tangled mess.
There are valid reasons to have varying quality of code and also the idea of quality might be changing from problem to problem and project to project.
A quality of code that governs your car's ECU should be different from quality of code that some research team threw together to demonstrate an idea.
A coding project should achieve some kind of goal or set of goals as efficiently as possible and in many valid cases quality is just not high on the list and for a good reason.
Right now I am working on a PoC to verify an idea that will take a longer time to implement. We do this because we don't want to spend weeks on development just to see it doesn't work or that we want to change something. So spending 2-3 days to avoid significant part of the risk of the rest of the project is fine. It does not need to be spelled out that the code is going to be incomplete, messy and maybe buggy.
There is also something to be said for research people to be actually focusing on something else.
Professional developers focus their careers on a single problem -- how to write well (or at least they should).
But not all people do. Some people actually focus on something else (physics maybe?) and writing code is just a tool to achieve some other goals.
If you think about people working on UIs and why UI code tends to be so messy, this is also probably why. Because these guys focus on something else entirely and the code is there just to animate their graphical design.