When shepherds move their sheep to summer pastures, they will go ahead of time to prepare the meadows and streams to be as safe as possible. They will look for a safe place to water them. They will look for dangerous areas that the sheep can be injured or killed. They look for areas that wolves or other predators may lurk. They familiarize themselves with the area.
The tops of mountains that are flat are called a mesa which translated means 'table' such as Table Mountain. Many of the mesas in the West are examples of what David is talking about.
When David says that God prepares a table, he is referring to a shepard's preparation for his sheep. Just as Jesus is preparing a place for us. John 14:1-4 tells us that He is going ahead of us to prepare a place.
Jesus is aware of the dangers we will encounter as we feed in green pastures. He is aware of the temptations and trials ahead of us. He is preparing our hearts for the times when we will fall into temptations. He is giving us the spiritual food to strengthen our faith and sustain us when the challenges of life drain us of our reserves.
Throughout the Bible, we are warned that Satan is 'roaming through the earth' (Job 1:7) seeking victims to devour. We need to be aware that he, Satan, is watching us very carefully to see where we are weakest. When Jesus prepares a table for us, He reminds us that Satan is watching what He, Jesus, is doing.
When Jesus served at the Last Supper, He had an enemy disguised as a friend at the table. He knew the plans Judas had but welcomed him to the table anyway. Jesus is aware of the plans of our enemy and still is willing to prepare a table for us.
Be aware that as we feast at the table with Jesus, our enemy is also present. Jesus wants us to feast with Him but also we must build our spiritual muscles so that we can stand strong and know the signs of the enemy's presence.