Having spent most of my career in R&D, I am constantly amazed by the fact that most folks keep the very same methodology no matter the budget, deadline, risk or importance of a project. Such people are one trick ponies that can only survive in a narrow set of environments.
Hackathons promote adaptation of approach. Spaghetti code is simply one possible result.
I highly doubt you'd find Linus Torvalds, DHH, Guido van Rossum or any other highly productive programmers competing in a hackathon. Maybe they have good reasons.
Also this is worth reading: http://www.thoughtworks.com/insights/blog/why-hackathons-suc...
But I think a better way to frame it is that hackathons promote streamlined MVPs which must be iterated-on and refactored at a later date to be sustainable projects. Some would argue that this is a fine business model, inside or outside of a hackathon setting.
If you're personally offended by bad code, that's fine, but hackathons are not shops on professional software development practices.