Petrified wood formed when ancient trees and plants were buried under layers of mud, sand or volcanic ash.
When buried deep enough the organic material was starved of oxygen which slowed the process of decay.
Dissolved minerals being carried in groundwater gradually filled pores and voids.
As the water dried up the minerals crystallised.
Over thousands to millions of years the crystallised minerals replaced the original cell structure.
Although it's often believed the wood turned into stone that's not correct. The organic material is always replaced with minerals.
The colours in petrified wood are determined by the minerals present.
Some petrified wood can look almost identical to the original structure.
It's only when touching some of these pieces that you realise they're stone, not wood.