Sorry to hear about your grand-daughter, but this is a very good question. Thanks for writing.
Having trouble with bowel movements like that is technically called "Encopresis." Once the problem begins, it tends to get worse because constipation is also frequently present, which makes toileting difficult not only from a mechanical standpoint, but also because it begins to hurt.
The problem tends to initially grow from one of a few sources: either (1) the child is feeling trauma or chaos - some sort of "out of control" feeling in their life/home situation that makes them want to bear down and control the only things within their control, namely, their bodies. Something as severe as sexual abuse can trigger this reaction, but so can something as common as parental divorce or constant arguments (2) there is some physical impairment that begins the problem of painful toileting or constipation, or (3) diet creates an allergic reaction or dehydration in the stool of the child.
With the addition of the temper tantrums, I immediately wonder if she is acting out something internally. In other words, is she feeling distress (anxiety/tension) in her life and is growing more oppositional and defiant in an attempt to deal with it?
If there is NO trauma or psychological distress based upon environment, I would also look for food allergies, dietary issues, or other physical problems. The tantrums may be driven by actual discomfort (a constant belly ache or cramping in the bowels) rather than psychological discomfort. You did not mention if the problem had been presented to the pediatrician yet, but s/he may be able to determine if there is a simple solution.
Behavioral therapy is certainly an avenue to explore, and no your grand-daughter is not too young to begin that process... but I would also expand my search for answers to include more global explanations.
I wish you well. If you are satisfied with the response, please hit "Accept." That is the only way I can receive credit for my answer. Thanks-