Almost by definition, someone's moodiness does not have a completely rational explanation, so I wonder if trying to understand the causes of it are fruitful.
When someone feels bad or mad or sad, or tired, or ill, or disappointed, or guilty, or shamed, or disrespected, or misunderstood, or jealous, or powerless, or tricked, or trapped, or insignificant, or used, or undermined, or is experiencing any type of negative emotion, a metacognitive moment may empower them to more effectively deal with their predicament, put it into perspective, shake it off, let it go, or formulate a plan to move forward. When people do not recognize or acknowledge their feelings, they may internalize anger (depression) or act angrily toward others.
Moods cannot be controlled
Some may disagree.
but outward behavior usually can be, so I think the focus should be on reminding the child that certain behavior is unacceptable rather than on understanding the root cause.
Possibly both are important?
What others experience externally of one's behavior is important.
What one experiences internally, developing positive self-talk and having a healthy relationship with one's self, is also important.
Lumped together, they're often referred to as social/emotional.
A rather frequent topic on the boards is children who are experienced as delightful, compliant, good natured at school... then may come home and express a day's worth of frustration. Generally, helping a child talk things out may help them learn not to act out. YMMV.