There's a HN post and comments which depict (repeatedly) consulting's Cycle of Despair:
At the heart of the Cycle of Despair is our failure to recognize its psychology. Economically, we're just hired guns: the code is owned by someone else, and we're being paid to change it. Psychologically, though, the longer we work with that code, the more we are adopting it; until one day some bit in our head flips, and it's now our baby.1 We get protective, and this causes the Despair.
Alternatively, imagine having several long-term part-time gigs. Most of the time we're working with cheaper talent, keeping them in line. The Company pays us a fixed amount each month for that management plus the option to pull us in for bigger projects at a non-penalty rate. The Company gets cheaper reliability, and we get paid to avoid the Cycle.
Consulting is not easy; we have to balance technical expertise with business acumen. There are tons of reasons why projects fail, however there are tons of "successful" projects where both company and consultant treated each other as disposable.2 Thankfully, the abusive nature of this is easy to detect.
The hallmark of a bad project relationship is our failure to maintain it.
1. Or some other metaphor, e.g.: you brought the code closer to its Platonic Ideal and now barbarians have debased it.
2. Good people want to work with good companies, and vice-versa.