Wood rot is an ancient and natural process. Preventing it is a uniquely human concern. As trees fall, they break down, decay, and erode into nutritious soil, returning life back to the earth and giving back to the ecosystem that once reared it. 
The source of wood rot (or more accurately, decay) is fungi that seek four things: water, oxygen, food, and the right temperature. Remove one of those and it upsets the balance for reproduction. The most common way is through moisture control.
If you're trying to figure out whether or not wood stain prevents rot, just know that it can if it penetrates the wood grain and seals it
There's more to that answer though.

How Wood Stain Helps Prevent Rot

Wood stain is colorant (pigment or dye, depending on the size of the wood pores) suspended in a solvent. There's an oil, resin, or alkyd that binds to the surface of the wood and acts as a vehicle for the colorant to seep into the wood layer to protect and saturate it. Wood stains that include a commercial sealant in the formula will protect the material and ward off absorption of water.
If you get rid of water, then fungi don't have the opportunity or ability to reproduce. This is the key to wood stain preventing rot. Another option to preventing wood rot is borate wood treatment to help kill any bug or fungi infestations.
It would seem that paint could be equally as helpful, right? It covers the entire surface and shields the wood, but not for long. It's just not that durable over time. Once it cracks or weathers, its seal is compromised and the wood beneath is exposed to the elements. Once that happens, moisture and fungi start mixing and mingling. 
Keep in mind that a clear stain can be used if one prefers a natural grain, so while maintaining the structural integrity, you can also maintain the aesthetic integrity, if so inclined.

Types of Wood Rot

The whole point of negating wood rot is to maintain structural integrity. What eats away at it? As mentioned before, fungi. They cause three types of decay: brown rot, white rot, and soft rot.
If moisture content stays below 20 percent, then generally speaking wood can avoid being attacked. If oxygen is removed, then fungi cannot thrive — this is usually accomplished by submerging it in water. Extreme temperatures for the fungi prevent growth (below 50 degrees) or kill fungi (above 200 degrees).
Brown rot on wood displays a reddish-rusty color and attacks cellulose with hydrogen peroxide to consume it. Over time it turns the wood into crumbly cubes, officially known as cubical fracture. Often referred to as dry rot, it dries out and fractures the wood, splitting it and causing strength loss. It thrives in temperatures between 65 and 90 degrees Fahrenheit. 
White rot deterioration is slower than brown rot and won't affect the surface much in the beginning. The innards will become a spongy, soft mass that can support very little weight or stress. Just as with brown rot, it thrives in temperatures between 65 and 90 degrees Fahrenheit. 
Soft rot affects wood in long-term moist environments, with the fungi species feeding on either the carbohydrates in the wood or on the lignin that holds cells together. This type of rot thrives more in extreme temperatures than the other two — 0 to 110 degrees Fahrenheit. It leaves the wood looking like a honeycomb on the inside.

How Fungi Get There

Fungi spores, think of them as tiny seeds, carry on the wind and settle onto horizontal surfaces. Impressively resilient, they can go dormant in extreme weather conditions.
Wood rot happens beneath the surface. Mold and mildew are not the source factors of wood decay; they live on the surface and cause their own slew of issues. 
Fungi eat away at cellulose, hemicellulose, and lignin. These are what make up wood cell walls. Essentially, fungi extend hyphae (tubes) into the wood and dissolve part of it so that it can be turned into grub. 
Think of fungi in three parts:
  1. The fruiting body is the reproductive stage, which if found is much easier to identify the rot.
  2. The mycelium is the body and the hyphae are what compose the mass of it. Through the mycelium, enzymes are secreted to break down those three parts of the wood into materials like simple sugars, fueling the fungus.
  3. Strands are in some rots, and they transmit food to the rot through thick hyphae.
Once the wood is in a form that can be consumed, fungi gets to work. Although the purpose of this article is to discuss wood-decay fungi that attack dead wood, keep in mind that it also colonizes living trees as well.