So we had a major upgrade project. Our old authentication software on old hardware was going to be replaced with new software, new hardware, and a new architecture made possible by the features in the new software.
Months of planning, rearchitecting, tripping over bugs ("oh, it's fixed in the next major version"), and testing, and it turns out that the software from vendor A does not work acceptably on the hardware from...vendor A.
Throw the plan out, and start from scratch on new hardware. Halfway through, vendor A (who by this time has been bought by Vendor B) changes their licensing/maintenance model, such that it will cost us an extra million and a quarter dollars (!!!) PER YEAR (!!!!!) to use their crappy software. Add an extra $50k to license their OS if we don't buy hardware from them.
(Yes, you can probably guess who A and B are :-)
Lucky for us, a new vendor rose from the ashes of an exploding corporate division, and is writing competent code. They also seem to be capable of supporting their own product. Not everyone is as "lucky" as us though, to make something work the third time.
To be fair, the $1.4 trillion in software costs will have little or nothing to do with the 40% of failed projects. Nobody of a reasonable size pays for software until it goes into production.