This phrase is almost like a verbal talisman, designed to ward off bad luck after tempting fate: "Breaking that mirror didn't bring me any trouble, knock on wood."
The fixation on wood may come from old myths about good spirits in trees or from an association with the Christian cross. Similar phrases abound in multiple languages, suggesting that the desire not to upset a spiteful universe is very common.