Now other times in the movies its probably the fighting conditions or their helmet reduces their accuracy due to the way its built.
Their bad aim is because on the Death Star they were ordered not to kill Luke and his friends. They wear imposing white armor, which offers a wide range of survival equipment and temperature controls to allow the soldiers to survive in almost any environment. Stormtroopers are elite shock troops fanatically loyal to the Empire and impossible to sway from the Imperial cause. They serve a fascist power that is known for, among other things, enslaving planets and races, seizing territory and resources without legitimate claim, imposing martial law without provocation, and generally disproportionate response to civil unrest. Yes, Stormtroopers are really the bad guys.