It sounds as though this child is confused with her situation, and is reacting to it in the only way she knows how.
At this age, she can be reasoned with. While she is good, her mum should praise her, epmphasising how nice it is when they are nice to each other, and how happy it makes her. Then, when the child is naughty, she must say that she is unhappy, and doesn't want to be with her child lkike this, and then absent herself until the tantrum subsides. Tantrums are attention-seeking - remove the attention, and they often stop quite quickly. So apart from stopping the child harming herself, she should be ignored as far as pssible, and see if this tack works.
Have a word with her nursery / school teacher and get them on side with the circumstances so they can encourage good behaviour.