When a tree falls, it decays rather quickly because of the action of wind, rain, bugs, and such. However, when a tree falls and is immediately buried, as can happen during floods, mudslides, or volcanic activity, possible outcomes can vary. In an environment with little-to-no oxygen, decay likely will be slowed and the tree might be preserved in some form. In some soils, the buried tree will remain just that — a buried tree, which decays slowly.
When trees become buried in a mineral-rich area, however, some amazing changes can take place. Under certain conditions, the walls of the cells in the tree can be replaced by silica (also known as Silicon Dioxide, SiO2), hardening them, essentially turning them into stone while still preserving the basic structure of the cells. Then, slowly, the organic material within the cells might be replaced with silica or other minerals, completing the process over time. Eventually, virtually all the organic material in the tree could be replaced with inorganic minerals, the same inorganic materials from which rocks are made. That is the 'petrification' process. 
The resulting object is an exact copy (in appearance) of the original, but rendered in stone instead of organic compounds. It has the hardness of the minerals that now compose it, and is resistant to further deterioration in the same way a rock would be.
Quite by a happy accident, I just learned that today, October 13th is National Fossil Day. How appropriate to be writing about one of the many types of fossils today!
The above photo shows what I consider the obverse (or front side) of the petrified wood specimen I have. The pretty colors visible in the piece are caused by trace amounts of various elements such as iron, chromium, et al. The side that I consider the reverse (back side) of the piece has much more subtle coloring, shown below.
While looking closely at the specimen not long after I acquired it, I noticed something quite interesting. In much the same way that one might look at a cloud and see the shape of a cat or an elephant, a scene unfolded in my mind when I looked at this piece. I marked the scene with a box, below.
There is a yellowish spot that looks like a crescent moon. In another place, there is a shape that almost looks like a humanoid figure (stick figure) with a head, arms (one raised), and legs, and it appears that figure is carved onto a boulder. Many ancient peoples carved scenes on boulders and cave walls and those are called petroglyphs. 
Enlarged and rotated, the scene looks like a painting executed by Mother Nature. I call it "Petroglyph by Moonlight." Can you see the crescent moon to the left, and the humanoid figure carved into the boulder?
I think this is a beautiful, colorful piece! It is delightful to hold in the hand and marvel at the forces of nature that went into creating it! While holding this specimen, I am connecting with a tree that lived thousands, or millions, of years ago. I am thrilled to have such an interesting and unique piece in my geological collection of rocks, minerals, crystals, & fossils!