IBM's problem in the PC market was that it was a high end brand in a low end market. Build quality? Sure, that just makes it expensive. Customer service? That doesn't make it faster. IBM approached the market with the mainframe mentality, where build quality and attention to detail were essential for machines running businesses 24/7. However, given what PCs were designed for, and the low end of the market they were targeted at, quality was irrelevant - if it breaks, replace it. In this regard, selling PCs has more in common with selling microwaves than selling mainframes.
It pays to know your market - Apple found this out the hard way in the days where Jobs was at NeXT and they tried to make low-end Macs - Apple works off snob value, remove that, and they removed a key part of their selling model. In a somewhat similar way, IBM worked off offering quality and service at a high price. Such a tactic can't really be adapted to a market that does not really want quality, but wants low cost.
Yes, I compared IBM and Apple. I probably have only 5 minutes to live now =P
There was also bad management - earlier PCs were deliberately castrated to prevent competition with the System/3 minicomputer line. The PS/2, which could have advanced PCs by quite a bit was a failure because IBM used it as opportunity to give the finger to it's competitors, except it kinda exploded in their face. Like most of its contemporaries, they had no idea what the microchip and decentralized computing would do the market.
Really it just ended up with them selling standard computers and using their name/image to shift units. Some of the later IBM desktops were little different to what the competition had in terms of build quality. Perhaps it was better for their dignity that they didn't sell out like HP did. (and the likes of DEC did rather unsuccessfully.