“Knock on wood” came from the belief that spirits resided in trees and knocking would call for their protection or prevent bad luck. Over time, the practice evolved into a common superstition to avoid jinxing yourself after saying something.
Learn more at https://www.history.com/articles/why-do-people-knock-on-wood-for-luck

