My personal opinion is that it has to do with the kind of people starting and running the companies (startups) that hire programmers in the first place. Company culture, after all, obeys the law of gravity like most things in a company. And I think it would be a useful exercise to study the source of the culture propagated in the stereotype you mention.
Given that the last few iterations of the computing revolution (Gates & co. to the Steves for PCs, Page & Brin to Zuckerberg for the web) have been shaped by bachelor university students or dropouts, all of whom embodied the code-until-burnout all-nighter lifestyle, I see what you mean. It's not just the people starting the companies- it's the people who started the fields!