In the Transformers film series, common household electronics like cellphones, radios and blenders are often turned into Transformers when they come in contact with the AllSpark energy. Why are these new Transformers always evil, trying to shoot everything around them? Is there an in-universe explanation for this behaviour?
They're the Transformer evolutionary equivalent of a wild ape. The All Spark gave Cybertronians life eons ago. Since then the Cybertronians have evolved and created civilization and culture. The freshly-created Transformers are devoid of all that, and are basically wild animals.
Another option offered by one of the film's writers is that due to all the recent advanced technology being reverse engineered from Megatron, it's conceivable that bringing this technology to life animates some of the evil essence of Megatron. (Source)
The way I see it, when a new transformer is created by the all spark it is given consciousness but not context. When humans are born there are a ton of cues to inform the child of familial connection. A Nokia phone suddenly given consciousness doesn't have any thing like that. Even if it does it is surrounded by large creatures that are in no way "like" it. And it is armed. If you suddenly gained consciousness, surrounded by T-Rex, with a machine gun in your hand and the knowledge to use it, how would you react?
Or there is @Keen's, built on technology from Megatron, answer which is just as likely.
This was discussed by Transformers Scriptwriter Robert Orci in a forum exchange on the (now defunct) official Transformers Movie website.
Q. In the film we see that the "All Spark, Matrix" or whatever is really called turned whatever machine it touched into a killing bot! Why is this? Is it because the device was originally intended as a weapon and so are it's creations? If so it would not surprise me since in Science fiction most machine races start out just that way anyhow...
Orci : It is meant to power Cybertron, not adapt human technology. Also, since all Earth's tech is reverse engineered from Megatron, maybe that affects the outcome, too.
Q. How come the Allspark created TFs were all Decepticons?
Orci : Prime intended to use the Allspark to repower Cybertron as it was intended. Megatron wants to abuse it by creating Transformers directly, which makes souless, primal Transformers.