Contracts for non-Agile processes are pretty worthless too if the project happens like this. If I understand correctly, the client ended up swallowing the cost for being intentionally lied to.
In an Agile process, the client would be much more closely involved with the development, attend sprint reviews, ask questions, and be available for questions about whether to drop features or extend the deadline. The client can make an informed decision and sound the alarm when too much time is spent on things they don't need.
It can work, and it has to, because the vast majority of companies in the world simply cannot write their own software. The problem is big software companies that mostly exist to leech of those other companies' lack of understanding of software. Basically every company that outsources software still needs to have at least one person who understands software development and project management sufficiently to keep an eye on the development process and check that they're not being scammed.
In an Agile process, the client would be much more closely involved with the development, attend sprint reviews, ask questions, and be available for questions about whether to drop features or extend the deadline. The client can make an informed decision and sound the alarm when too much time is spent on things they don't need.