I think generally it is a power struggle, coupled with feeling frustrated, the toddler cannot clearly communicate what they want and why. They are finally aware ebough of their environment that they want things, but they have no control over being ale to have those things, other big people are controlling it.
Part of it is also testing adults. If they cry and get their way, then they learn crying helps them get their way. If it doesn’t work next time, they cry and scream more, and then if they finally do get their way, well you see the pattern.
I think part of the reason toddlers don’t have tantrums when they are alone, as @rooeytoo suggests, is partly because no one is there to witness it, but also because if they are left alone, they are probaby in a place that is safe for them, and they can have whatever they want in that space, because no one is stopping them from having what they want.
I agree hunger, and being tired adds to the probability of a tantrum happening.
Lastly, sometimes kids are prone to hyperventilating, and they upset themselves into a scary state, and then they really are freaked out, and feel physically awful.