After the Clone Wars ended (Episode 3), Palpatine needed to solidify his power to reorganize the Old Republic into the new Galactic Empire. To do this his needed a much larger army (more than the existing clones) and also needed to generate popular support, so he instigated a new propaganda campaign to instill loyalty and patriotism by turning many of the higher learning centers into Imperial Academies (Luke Skywalker was attempting to apply to such an academy so that he could get off of Tattooine) where regular humans were educated and simultaneously trained to serve in the Imperial military as officers, technicians, pilots, and soldiers. In the roughly two decades between Episode 3 and Episode 4 (the original Star Wars) the majority of Stormtroopers were normal humans that graduated from Imperial academies and recieved advanced training from one of the Imperial Military Centers, like the facilities on Cardia.
The defeat of the Emperor and the destruction of the second Death Star over Endor didn't mean that the rest of the Empire and the stormtroopers just rolled over and gave up. George Lucas created a new ending for the "Special Edition" of Return of the Jedi showing clebrations taking place right after the second Death Star is destroyed. This was the "Hollywood Happy Ending" for the Star Wars movies. Before the release of the "Special Edition" movies, many novels (and a few comic book series) from the "Expanded Universe had already been written, all based on the more "realistic" aftermath that the Alliance victory at Endor was only the turning point in the Galactic Civil War and that there were still many remenants of the Empire to defeat before the New Republic could be established.
With Palpatine dead a few Imperial officers, pilots, and troops (including non-clone stormtroopers) that had become disallusioned with the Empire's New Order broke away and either openly sided with the Alliance or became civilians. An example of such a disallusioned stormtrooper was introduced in the novel "Tales from the Mos Eisley Cantina", he was Davin Felth, the sandtrooper that finds part of C-3P0 and says "Look, sir, droids."
In "Truce At Bakura", which takes place the day after ROTJ, the stormtroopers were still loyal to the Empire, but had to join forces with the Alliance in order to protect the Imperial colony on Bakura from the invading Sri Ruuk.
There is a span of about 20 years after ROTJ, known as "The New Republic Era", where the Empire (in one form or another) continues to oppose the heroes of the former Rebel Alliance. The stormtroopers follow various Imperial "Warlords" trying to grab new leadership of the crumbling Empire. Then 5 years after ROTJ a near-human alien Grand Admiral, named Thawn, returns from exploring the "Unknown Regions" and creates a new clone army of stormtroopers using cloning equipment from one of Palpatines hidden technology caches. After he is defeated, the stormtroopers follow a Clone of Palpatine, and then other Imperial remnants (like former members of the red-armored Royal Guard). A little over a decade after ROTJ most of the Imperial remnants have been smashed into a completely disorganized group and the New Republic has the majority of control as the galactic government. By the end of the "New Republic Era" the last remnants of the Empire sign a peace treaty roughly 20 years after ROTJ and finally ending the conflict between the Empire and the Alliance, but there is no rest for the New Rebublic.
Shortly afterward at the start of the "New Jedi Order Era" the known galaxy is invaded by the Yuuzan Vong that lay waste to entire worlds by using their biotechnologies to not only enslave others, but to alter their biology, terraform their planets, and also alter the biology of every plant and animal that exist on the world.
Star Wars novels, comics, and video games that form the "Expanded Universe".