There are two main reasons. One is that scientists, are not professional software developers. That's true even for computer scientists, and more so for mathematicians, physicists, chemists, biologists, social scientists and so on. Not that they couldn't, most people who are reasonably clever could become professional software developers if they wanted, but most are not.
Two is that scientists are not interested in creating whatever would be the opposite of "horrible software". They are usually only interested in the results. Where this is bad is if their software contains bugs that produce results that are wrong, but close enough to the truth to seem plausible. Fortunately, many bugs will produce results that are obviously wrong. It is also bad if the software is confusing enough that nobody can declare for sure whether it is correct or not, but to my knowledge there are not many complaints about that.