Under what conditions does market failure occur? Edit: Is it possible to broadly categorize the ways in which market failures occur into relatively few categories? If so, what are they?
Any situation where markets fail to clear leads to market failure. Some common reasons for this are:


Externalities, or agents not being responsible for costs or benefits of their actions
Information assymetry, or agents operating with different information
Irrationality, or agents doing random things for no reason
Principal agent problems, where someone entrusted with others funds uses them wastefully
Productive inefficiency, or firms failing to produce goods effectively given the allocated capital (think using Gatorade to water plants)
Allocative inefficiency, where firms are not provided the appropriate capital
Economies of scale, or the problem of capitalist firms failing to grow large enough to establish a service
Destructive competition- eg, private militaries blowing each other up
Shortsighted management of natural resources 
Monopoly
Moral hazard, adverse selection, and other problems in contract theory