God spoke to Joseph, the carpenter, in 4 dreams to guide him in protecting Jesus and Mary. The first dream told Joseph to marry Mary. The second warned of Herod's plan and told Joseph to flee to Egypt with Jesus and Mary. The third instructed them to return from Egypt after Herod's death. The fourth dream warned about the region under Herod's son's rule, guiding them to Galilee. Joseph obeyed God's messages delivered in dreams, demonstrating the importance of listening to and obeying God's instructions.