There are many things that can cause a bad attitude. There is not one. I am not exaggerating or over-stating this point. I have seen many a good tech go down this road and end up bitter, difficult to work with and in some cases, unemployable. In most cases we don't make a conscious decision to develop a bad attitude.
Negative situations are the fertile ground, which cause negative thinking.
Negative thinking will build a bad attitude. Let me give you an example. I am going to make this situation even worse. Harry can't afford to quit and there are no other jobs. He can't afford to move - he is, just stuck in this nightmare.