Planetary Defense Force
"To save our mother Earth from any alien attack
From vicious giant insects who have once again come back
We'll unleash all our forces, we won't cut them any slack
The EDF deploys!
Our soldiers are prepared for any alien threats
The navy launches ships, the air force send their jets
And nothing can withstand our fixed bayonets
The EDF deploys!
Our forces have now dwindled and we pull back to regroup
The enemy has multiplied and formed a massive group
We better beat these bugs before we're all turned to soup
The EDF deploys!"
- – Earth Defense Force 2025
In Warhammer 40,000, a Planetary Defense Force is, as the name suggest, an armed force that protects a single planet (as opposed to the Imperial Guard, which travels from planet to planet). They have a tendency to respond to any major local threat, then be killed to a man.
The Imperium of Man is a very feudal empire; while much is made of the Space Marines and Imperial Guard, they cannot be everywhere at once, and so each world is expected to be able to protect itself. On civilized worlds, the PDF fill that role, either fending off attack entirely, or holding out long enough for off-world assistance to arrive.
We never hear about their victories, partly because stories where the PDF wins are not as interesting as those where the Imperial Guard and Space Marines have to get called in, and partly because most planets make their Imperial Tithes by bundling the best few percent of their Planetary Defense Forces into IG Regiments and shipping them off-world. It is also important to remember that sitting on a safe backwater planet for centuries means that they have absolutely no combat experience compared to IG regiments that are shipped from one warzone to another. Add to that they have even less equipment, no comm-beads for individual soldiers, and that for an entire system of planets a single Commissar is attached. Ironically, planets with a Feral Orks infestation tend to have a better PDF and produce better IG regiments. However, the average PDF unit tend to fold like wet paper when a significant off world threat arrives. As such, the Imperial Guard consider them grossly undertrained, incompetent, and poorly armed compared to the Guard. The irony of this is lost on the Guard itself. Better yet, it highlights just how bad it is to be a member of the PDF.
Another major problem for the PDF is lack of experience and as a result, morale. PDF from a forgotten backwater planet do not typically see a lot of action and as a result lack any combat experience. Add to this that most information sources available to them are comparable to the IG uplifting primer (and they don't have anyone around to tell them what a pile of grox*BLAM*Heresy!) and you can see why facing the untold terrors of cosmos might go south very quickly for them.
To be fair, not all PDF are incompetent pushovers. For example, Cadia's entire population was militarized from birth, in reserve if not in active duty, and those active duty Cadians who were selected to stay instead of being shipped out to the Guard were chosen at random instead of by lack of merit. This means that Cadia's PDF was every bit as skilled and tough as any of the planet's many exported Imperial Guard regiments, and train just as hard, just as frequently, and were just as well supplied for being on a fortress world. The shipped regiments were also rotated frequently enough meaning that most Cadian PDF actually had some combat experience. However, examples like this are the exception rather than the rule when it comes to PDF quality. Especially considering recent events...
Often, when PDF aren't incompetent, they turn traitor. While an Imperial Guard unit is constantly shuffled from world to world, only resting in transit, and under the watchful eye of a Commissar, the PDF may go for years or even lifetimes without seeing a planet-scale defensive effort. As such, they often also serve as local law enforcement. This can result in the PDF being more loyal to the planetary government than to the Imperium; if the planetary government turns corrupt, they can bring the PDF with them, which makes it that much harder for the Imperium to reclaim the planet later. Also, even if they did not turn traitors they are the most suspected people if heretical cults are active on the planet, and they usually are, or the planet got infiltrated by Genestealers. Thus even if a problem arose the guards would still avoid them and the authorities would still distrust them to use them so that they might gain combat experience.
The three notable exceptions to this rule are the Armageddon PDF, who often fight the Orks still on the planet, as a result of a lower than normal Tithe for a planet of its size allowing the Armageddon PDF to be well trained and funded. The other is the Ultramar Auxilia, as Ultramar has no tithe due to supporting the Ultramarines Space Marine Chapter, also since they must meet the standards of Space Marines resulting in higher than normal training, generally they are still shipped offworld like normal guard and often support the Ultramarines. And the last is the Cadian Interior Guard whose members are chosen from one out of ten best men in the Cadian Shock Troops Imperial Guard regiments.
The greatest irony is that if the Imperium would only enforce the training of planetary defence forces to a decent standard (as they are so eager to get their mitts on your tithes!) then the heretic and xenos would have a damn harder time taking over worlds and the guard and marines won't have to keep running in to save them and could actually concentrate on the full scale invasions (But of course that much common sense won't be at all grimdark enough....). Not to mention the fact that if the Imperium were to require worlds to also have their own law enforcement that is controlled by, trained by, and generally indoctrinated by, the Adeptus Arbites, you wouldn't have to worry much about A) crime (pickpockets would be shot, soooo...yeah) or B) turncoat PDF (because of fanatical loyalty to Imperial law). So then you would technically have two competent fighting forces on the planet, both of which are separate enough from local affairs to remain loyal to the Imperium. The PDF and the local law enforcement. Then the Guard to concentrate hundreds, perhaps thousands of regiments on threats instead of a few dozen. Not to mention how much hurt the Astartes would be free to lay down. However, it's questionable whether such indoctrination would work. One of the reasons that the Arbites are so loyal to the Imperium instead of the planet they're stationed on is because they come from a different planet.
In general, in cases where PDF would get the opportunity to gain the experience and funding necessary to become a reliable fighting force, they don't tend to keep the title of PDF for long. However, the PDF do their jobs as well as they can with the equipment they have, and typically its only confirmation bias that they get such a bad rap (If deservedly so). Usually they are sufficient enough to keep the peace and fend off minor threats like a small savage Ork incursion or petty bandits.
PDFs also have a couple advantages over Guard. As stationary forces, they have a home field advantage. Planets in the Imperium run the gamut between "nice enough" and "kill you if you look at it funny" so being able to utilize a world's natural defenses and terrain is helpful. The First Siege of Perlia is an excellent example of this principle in action. During this campaign survivors of the local PDF used their local knowledge to wage a months long guerilla war against the invading Orks. They caused so much chaos behind enemy lines that the Orks were forced to divert large portions of their forces in an attempt to hunt them down, which significantly eased up pressure on the remaining Imperial held areas. The Imperium was ultimately able to easily retake the planet when the "heroic leader" of this ragtag force accidentally stumbled into the Ork HQ and killed the Warboss, making this one of the few times the PDF actually Got Shit Done. Secondly, PDFs can utilize stationary gun emplacements and shield generators (or even space stations defense). It is remarkably difficult to shoot through a world with anti-naval cannons and an exterminatus-resistant shield network. Generally PDF losses occur because the onus of victory is on the attacking force. That is, they only attack planets they can win against. Heavily-fortified fortress worlds can take centuries worth of orbital beating before they collapse. Take Vraks for example. While, yes it did go traitor, the fact that it took over 18 years to collapse shows just how long a well defended city (Remember Vraks only had one thing worth a damn about protecting on it. it was only ONE fortress) can last and what a toll it can inflict on it's attacker (that being said, Chaos interference and the orbit being contested also played a big part in that battle).
Also, there was one (yes, one) PDF trooper worth noting. Some family man with a forgettable name fought alongside Uriel Ventris of the Ultrasmurfs during a battle against Tyranids. When he ran out of shots for his lasgun, what did he do? He picked up a discarded chainsword and charged the 'nids with it! He actually managed to keep up with Ventris, an Ultramarines Captain. When a Carnifex came to blow them to bits with bio-plasma he ran back, grabbed a missile launcher, and shot it in the face! Then picked the chainsword back up and charged again. After the battle was over, Ventris visited him in the hospital and, in front of everyone announced that this man had saved his life and about how badass the guy was to keep pace with an Astartes. If you've played or seen the Space Marine game, you must realize how incredible a feat that is. Ventris then removed one of his purity seals and gave it to the man. Clearly, the mustering of the Guard missed one.
And the ones Ciaphas Cain hang out with in Death Or Glory.
In Star Wars the Galactic Republic had no national army between the 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 year 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 itself. 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 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, though 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 over. 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 defenseless 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 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.