I think it is very annoying how inconsistent SW is.
If we look at the very first time a Stormtrooper is on screen (Boarding of the Tantive IV) Where what appear to be 6-10 stormtroopers easily defeat 12-15 rebels with only three casualties. And their aim is spot on.
Then in the same movie, 8 troopers run into Han, Luke, Leia and Chewie in a corridor and Han shoots one, ONE, of them, and they all flee. I'm beginning to be confused.
Then, after Han chases the other seven the hall and into the hangar, what appear to be more than thirty troopers fail to hit one man in a cramped doorway.
The weirdness continuing, four stormtroopers cant even hit luke and leia from ten feet, while standing still. I am quite bewildered as to how this happens.
Then in ESB, A mere battalion of snowtroopers and five AT-ATs take out 7,500 rebel soldiers. Even if the entire battalion was killed it would still be a 9 to 1 kill-loss ratio for the empire. That doesn't seem like a feat a bunch of incompetent idiots could accomplish. ( Now, I understand that a considerable portion of the rebels were evacuated, but still the ratio would be similar because the battalion was not completely destroyed. For example if there were only 5,000 rebel troops and everyone died it would still be 6-1.)
And then to top the movie off, those same stormtroopers (The 501st was the force in both battles) cannot manage to hit Han and Leia as they sprint across an open landing platform from twenty yards away.
Yet in the final battle of the Return of the Jedi, those SAME troopers fail to shoot little teddy bears half the size of a human. What seems to be around two platoons of Stormtroopers (100 men) and four at-sts succumb to the immeasurable might of some spear wielding build-a-bears.
As I see it, Star Wars is not a reliable source when attempting to draw conclusions on Stormtrooper competence.