The April 1998 issue of Byte magazine did a good job of explaining this unfortunate state of affairs.
Sadly, the answer is it is a LOT of things and more than one of them affects more than one program on quite a few computers.
Here are some I can tell you right off the top of my head, via frequent experience or reading of other widespread problems in the press:
I. Hardware faults
A.) Hard drives eventually crash - rendering programs unable to read their data, their configuration information, or even their own programming code from the disk. In the old days, this was spectacular and the name was well-suited. I have stood in 1 or 2 computer rooms where when a hard disk crashed, it came flying out of a a hard drive at high speed and embedded itself in a wall. Nowadays the failure is less visible but the impact to software is just the same: it cannot read the data, and the drive is terribly damaged (even if the wall is not).
B.) Media wears out. Tapes and hard disks use iron oxide for magnetic storage. The magnetic fields and/or materials wear out over time and/or use. The media loses the information and thus it is "forgotten" by the computer.
C.) Communications transceivers wear out or get zapped or whatever. If the device that connects you to the network dies or gets unreliable, so does your connection to the network. This problem afflicts computers - and routers and other devices in the network.
D.) Bad high-speed capacitors are the culprit behind many computer failures in the past few years, especially on mother boards. A Taiwanese company tried to use a stolen Japanese electronic firm's recipe for making the electrolyte used in high speed capacitors of the sort becoming necessary in computers in the 2000s. Problem: the stolen one was chaff, designed to foil unscrupulous competitors who stole it. The caps work at first, but over time, the electrolyte breaks down, releasing small amounts of hydrogen gas. As you know and people unfortunate enough to take the last right in the Hindenberg found out, hydrogen ignites explosivelhy in the presence of a small spark. The caps bulge, leak electrolyte, and ultimately self destruct with little explosions. Thank thieves, unethical businessmen, and companies looking to cut a buck from their costs for that one.
E.) Bad power control hardware/sensors or fans. The computer with this problem will either literally fry its hottest-running components with too little cooling, or panic and shut itself down unnecessarily in the mistaken belief that this is the case. In the former case, the computer or part of it is toast - and in the latter case it is very annoying and lots of time/work is lost, plus the disk contents might become corrupted.
F.) Zapped! Electricity strikes on/near powerlines or buildings, a contractor at a power company crosses the wrong two wires, normal power fluctuations are just a little too much for a sensitive modern computer and there is no surge surpressor or UPS to stop it, or the power drops and a surge surpressor cannot maintain the power level needed (though a UPS would have).
II. Communications faults - I will not even bother to detail these, but trust me, they happen all the time. Here is a short list. Someone picks up the other phone on the line, interrupting your data-modem call, noise in the lines, too much traffic for a router to handle, a piece of networking equipment dies or fails to perform, something is configured wrong, etc.
III. Logic faults.
A. Failure to initialize a variable, these days often a pointer, to a usable value.
B. Bounds check is wrong or missing; program goes off the end of a piece of data, reading data or getting a smackdown by something that is aware of this and clobbers the execution thread, preventing it from causing further harm to other code/programs' data.
C. Bad error handling - you probably knew this one was coming, after seeing the long list of sorts of things that can go wrong in a computer. Most programmers are not aware of all the different types of logic faults, convince themselves they will not happen, are not "required" to handle faults/errors by program designers or supervisors, or lack training/knowledge of how to handle them. Little things escalate to big things in a sort of incrementally growing domino effect - and the program hangs.
D. failure to check return/error codes - sometimes programmers assume a file will not end at a certain point, that data that is forthcoming has already arrived from a communications line and it has not - that sort of thing.
E. bad device drivers - I have read of and seen many defective video card drivers on the MS-Windows platform. Since the drivers are given an "all-powerful" status, the smallest flaws in them can completely undermine execution of a program in memory. Small programming mistakes get magnified in this zone.
IV. Configuration faults.
A. Configuration files - the program is not set up right, or the configuration gets damaged.
B. You did not buy enough RAM for your computer; the seller/manufacturer built it with too little RAM - or programs simply got larger or more plentiful after you bought it. Buy more RAM, if the type your computer needs is still being sold and your computer can handle more. Get an antistatic strap and use it properly or have a good, competent technician who does install it for you.
V. Design/requirements/analysis flaws - you think programmers and hardware makers are the only people who make mistakes? Think again. Requirements analysts, systems analysts, software designers - they are all only human and sometimes they make mistakes too. They have to have imagination, foresight, domain knowledge, real-world knowledge, business knowledge, and so forth. Nobody knows everything or fails to overlook considering implications of a couple things they know - some problems creep in here too.
VI. Defective operating system - the OS is sort of the foundation for all the other software (device drivers, applications, etc.) in the computer, except for the firmware.
VII. Defective firmware - I do not hear about this all that often in computers, though it is not unheard of. More likely to occur in devices. One big reason why Flash memory became so popular, compared to non-rewritable ROM (read-only memory) that was prevalent back in the 1970s and 1980s era microcomputers.
VIII. running out of disk space - you could think that software applications and operating systems would handle this gracefully and you would be wrong.
IX. Concurrency issues - most programmers do not fully understand how to write multithreaded programs, handle resource contention from multiple programs, coordinate distributed processes, and do multiuser database programming. It is difficult and the way to design for these things does not really correspond to much in real life - it requires an ability to visualize or work with invisible abstractions. Programmers who intuitively grasp all these things and get the right trainining/studying do well, those that do not perhaps just reject both acknowledging the problem exists or the techniques for solving it.
There are lots more categories of faults and errors, but you get the idea.
Here is how these things play out:
fault(s) -> error(s) -> failure(s)
A fault, or a flaw, results in some kind of internal corruption in some programming, instead of being handled, causing an error.
Then the error condition that results is not handled either, causing a failure - a deviation from the requirements for how the program is supposed to behave.
Each part of a computer - hardware, software, configuration - even the operator/user and business processes/habits affecting its use, is very complex. The interplay between these things under ideal circumstances is more complex, and for very subtle reasons. This results in a reality that is very counter-intuitive, and very complicated compared to the ideal picture of "how things are" with a given computer or computer system.
When there is a fault leading to an error, and it is not handled properly - one of the types of failures that can result is an "application hang".
By the way, the links are wrong on the first source I cited from byte.com (which is a good example of the principles listed above), though the article titles in it are correct. I have given the corrected URL for one of the more interesting articles. You can probably find the rest in short order.