My own take on this:
Define who you want to defend the village against. Almost no village will be able to stop an army. That's why, when Sauron's hordes cross the Anduin or Saruman's orcs burn the westfold the villagers retreat to the Hornburg or Minas Tirith. That is one of the functions of a city. Nor will villages be able to stop dragons. If a dragon worthy of the name wishes to destroy a village of a few hundred people, he will. After several dozen such villages, he may attract the attention of a knight and be defeated but that's only after several dozen villages.
Then again, armies and dragons are hardly the only things in the D&D world and they're both fairly rare. What a village really needs to be able to do is defend itself against the orc tribes from over the hills or the viking raiders from the north sea. That means defending themselves in small skirmishes against groups of warriors who have come to raid and pillage rather than to conquer or destroy completely. So, there are a number of strategies that villages will employ in order to survive.
If the raiders take a predictable path (vikings come from the sea, and orcs might come through a pass from the mountains) they probably set up a watch on that particular path along with a signal fire. Even if their foes don't have to take a particularly predictable path, they probably have a watch set up and a signal fire--they just don't get as much warning out of it.
Now, for the defense of the village itself. Some villages will have fortifications. All of them won't, however, and a lot of the village's population will live outside of the fortifications even if they do have fortifications. So, the first order of business will usually be to retreat to relative safety with such goods as can be easily carried. The farms may be burned but they can be rebuilt. (There's a reason that frontier villagers tend to be hardy and persistent folk--they have to rebuild every so often).
Finding a raised piece of land for the village is a good start for defenses. If there is a hill near the village, it's probably where the fortifications are. It's probably also where the village granary, etc is too. If you're going to keep the village's stores, you're going to keep them somewhere where they can be defended. Now, the fortifications may surround the central village or they may just defend a small fort on the hilltop. Sometimes, the village won't even have a full-time fort and will, instead, have a building that doubles as a fort. I visited a cathedral in England--Lincoln cathedral IIRC--that was built with such a purpose in mind. (It was interesting to see the guard rooms and the holes for pouring red-hot sand on intruders in the gates of a church).
The fortifications themselves will depend upon the terrain. A ditch and dike is probably the easiest in most climates and will form the basis of a lot more defenses later. The ditch helps to break up charges and make a short wall more effective even if it isn't filled with water (becoming a moat). A palisade on top of the dike will make it more secure and is a lot easier to build than brick or stone walls. The palisade might be wetted down to keep it from burning or it might be covered with wet hides if there is time to prepare. A few towers or platforms for firing arrows from behind the palisade would be helpful and would probably be the next thing built.
It's likely that a frontier village is filled with the kind of self-reliant people who are handy with bows or crossbows anyway, but in a village that has to take thought for its defense, it's likely that they'll require all men to learn how to use a weapon in defense of the town and will keep at least some small stockpiles of ammunition in whatever location they've made defensible. In a small D&D village, this might easily be as simple as several hundred extra war arrows or crossbow bolts. If everyone brings their own crossbow, that's what will be most needed. In more prosperous areas, however, it likely includes a small supply of simple weapons as well as ammunition and maybe even some armor. The weapons will be selected on the basis of local skill and cost. A D&D village might have some spears or longspears (Commoners get proficiency with two simple weapons and, IMC, that's usually spear or longspear and light crossbow) and light crossbows. If there is any armor, it's probably leather or padded. (Cheap and no armor check penalty means that proficiency isn't required). Areas with militia as a regional feat (ala the FRCS Dalelands Militia feat or the Player's Guide to Arcanis Milandesian Canton feat) will usually stock equipment suitable to the feat. So, Dalelanders would stock arrows for longbows rather than crossbow bolts, and Milandesians will have halberds rather than spears. For the sake of simplicity, I would say that most regions will have one missile weapon and one melee weapon. The stockpile would probably also include a number of heavy wooden shields (cheap and efficient) though commoners would IIRC need to spend a proficiency to be able to use them properly.
Good missile weapons:
light crossbow (expensive but the most effective simple ranged weapon)
sling (cheap and, if you're willing to use rocks rather than bullets, you can save money on your ammo stores--most stores, however, would probably be bullets. If you're going to build a space, you want to store something good in it).
javalin
shortbow (sure, it's a martial weapon, but human commoners have two feats and this could be one of them. Historically, a lot of commoners knew how to use bows and they're easier to build (and cheaper) than crossbows too).
Good melee weapons:
Longspear (Especially in areas where size: large attackers might be common or in highly organized areas where men would train to fight in units)
Spear (solid damage and crits, set vs. charge, cheap, efficient).
Morningstar (again, cheap and efficient)
Dagger (more for people who want to carry a concealed weapon than for general fighting, but it might be a good depiction of the sax, etc.)
Club (it sounds very basic, but they're cheap and easy to make and some cultures actually did make extensive use of clubs in war).
Though categorized as simple weapons, maces are second only to swords in symbolizing authority, etc, and would probably not be the first weapons of commoners--in D&Dland or anywhere else. Furthermore, they use a lot of metal and are not as cheap as some other alternatives.
As for the leadership of the village/town in times of crisis, if the town is organized, there would probably be a militia or muster leader with some levels of fighter or warrior. Odds are good that this individual spent some time in one army or other as a recruit or a volunteer. The militia might well be organized along military lines and trained in the usual tactics of the day. (In the German peasant rebellion of 1525, the peasant armies were organized along the same lines as mercenary companies of that day... because most of the leaders were former mecenaries. The biggest difference between the peasant armies (which came from mostly villages and towns) and the princes' armies was that the peasant armies had relatively few cannon or trained artillerists and those all came from the larger towns).