Planetary Defense Force (Star Wars)

"This is a dangerous situation, your Highness. Our security volunteers will be no match against a battle-hardened Federation army."
- – Quarsh Panaka, head of the Royal Naboo Security Forces, to his Queen
In the galaxy far, far away, the Galactic Republic had no national army between the Ruusan Reformation (1000 BBY) and the start of the Clone Wars (22 BBY, less than 3 years before its demise) besides the small Judicial Forces (if you want to know the exact reasons behind this, read the relevant section of the Star Wars Setting article or go on Wookiepedia, people were pretty damn tired after thousands of years of war that ultimately lead to a three hundred years dark age when the last two thousand of those were near constant fighting), instead each planet was responsible for the security of itself and its system with its Planetary Defense Force (also called Planetary Security Forces). This worked fine in the developed Core worlds and Inner/Mid Rim but proved to be a problem in the low population and underdeveloped Outer Rim where there were vast stretches of unpopulated and underpopulated systems for pirates to hide and ambush from, and simply many of the systems not being able to afford it.
This gave rise to the Trade Federation which, to ensure the security of its trade operations, created the Trade Defense Force in 297 BBY. The TDF won the hearts and minds of many in the Outer Rim and Outer Mid Rim with its extermination of pirates. In 32 BBY, the Trade Federation realized the obvious: They held more military power than the Republic. When Naboo violated their contract that guaranteed the Trade Federation exclusive exploitation of their plasma resources, the Trade Federation took the opportunity to blockade them, both to punish them for violating the contract and demonstrate to the Republic why they should retract some recent tax increases. This incident, combined with Palpatine playing both sides so well that he essentially commanded both sides of the crisis, would lead directly to the Clone War and Palpatine using it to purge the old Jedi Order and make himself near undisputed galactic dictator.
During the Clone Wars, PDFs were often forced to defend from Confederate forces on their own or attached to Republic forces for offensive action. This (and crew for second-line navy vessels and officers in the first-line vessels) is the source for all the non-clone, non-Jedi people in the pre-Episode II EU saying they fought in the Clone Wars when they were younger. After the Clone Wars, PDFs were fully nationalized by the new Galactic Empire. Loyalty was quite low and, after the formation of the Alliance to Restore the Republic in 2 BBY (possibly earlier with the groups that would form the Alliance), large numbers of PDF personnel either defected or allowed supplies and equipment to be stolen. This is why the uniforms, blasters and Y-Wings are all relatively standardized in the Rebel forces despite their lack of standard industry.
After the destruction of the second Death Star in 4 ABY, the ability to once again keep privatized PDFs was used to entice worlds into joining the New Republic (though without giving up the overall New Republic Navy and Army initially formed from Rebel Alliance veterans). This proved quite successful and helped the New Republic hold against the Thrawn Campaign and Palpatine's rampage after revealing his survival when transferred to a series of clone bodies. However, it also led to members using the Caamas Document Crisis in 19 ABY causing weakness and division within the New Republic as an excuse to go to war with each other. An attempt to limit PDF sizes in 32 ABY, and Leia's older son (the young one died in a suicidal battle in the Yuuzhan Vong War after feeling guilty over having to leave Chewbacca behind) falling to the Dark Side, lead to the Second Galactic Civil War.
Unless you're talking the Disney canon, where most worlds of the New Republic disarmed their PDFs and reverted to the bare minimum force necessary to maintain planetary security and not much else, even though the Empire wasn't defeated. The money saved was then spent on "peace dividend" projects, much as was done in post-Cold War Europe, and to rebuild planets devastated by the Empire. Of course, this left the Republic defenceless when the First Order decided to conquer the galaxy. Much as during the Galactic Civil War, decommissioned PDF supplies and equipment were used to build The Resistance, though in this case, it was far less successful seeing as The Resistance only ever numbered a few thousand individuals and no more than 5 capital ships at any given time. Ironically, the First Order was permitted to maintain its own warships as a sort of System Defense Force for the regions it controlled; they just pretended that the fraction of ships and soldiers publicly seen were the entirety of their might, and so suckered everyone in the galaxy except Princess Leia into believing militaries weren't needed because nobody noticed any of the giant ships with crews of thousands or had no intelligence about an area and presumed nothing was there.