For me, it seems to be a combination of tiredness, sleeplessness and stress. Those combine perfectly at work. It has bugged me. I've often thought: if I'm "acting out", being "short" with others or driven by stress, how exactly can I be an ambassador of Christ in my location?
It's important to spot patterns and stop them evolving into habits and eventually into a lifestyle. It's even more concerning to realise that the bad attitude wasn't confined to location. I was "acting out" beyond the workplace and I was convicted on this recently.
I had been awake for nearly 20 out of the 24hrs in a day and generally had not slept much that week. It must have been evident on my face because I received a kind question from a concerned individual but responded inappropriately. I was not yelling or being overtly rude but internally I knew I was.
If I've done something wrong, I know 'cos guilt is very real for me. Ephesians 5:1-2 "Therefore be imitators of God, as beloved children; walk in love, just as Christ also loved you and have Himself up for us..." If there's anyone who'd understand being overwhelmed, it's Jesus. He had crowds of people surrounding Him wherever He went. He had followers seeking advice. He never told them that they were too "thick" to not be able to perform miracles like they had seen Him do. He never got irritated at the crowd for their endless need.
As I talked to God about my "emotion-driven" episode, I opened 1 Corinthians 13, the scripture that tells us all the wonderful things about what love is. My attention was drawn to a few things: "love...is patient, does not dishonour others, is not self seeking, is not easily angered, does not delight in evil but rejoices with the truth"... Literally in there was the answer to "acting out", due to stress or whatever else. There's nothing honourable about being rude to a colleague, brash in your responses or irritable and angry towards mistakes. The person you're being irritable with might really need your help that day, they may need some encouragement and they may be having a rough day themselves.
But what does love have to do with it? 1 John 4:7-8 "dear friends, let us love one another, for love comes from God. Everyone who loves has been born of God and knows God. Whoever does not love does not know God, because God is love". You've identified it's a bad attitude. You know the reasons. Nip it at the bud. Tired? Need to get a bit more sleep? Reduce workload? Manage time better? Re-arrange your schedule? Do what is necessary to take out the root cause of that attitude so the people around you don't bear the brunt of it. Galatians 5:16 "Walk by the spirit and you will not fulfil the desires of the flesh"