In 2 Samuel 5:24 it is written: "[You are to] move quickly as soon as you hear the sound of marching in the tops of the poplar trees..."
Most likely the sound of [the Lord] marching was not different than the sound of trees moving at the blowing of winds. When wind blows on a tree, it starts moving swaying back and forth beginning at the top.
Imagine you in the shoes of David positioned next to a poplar tree. If you knew how to hear the Lord, you could recognize the tree tops moving as the sound of the Lord marching. Otherwise you would not know the difference, so you would not go for the victory.
Question: how did David inquire of the Lord? How did the answer come to him? In view of the practices of the kings in the day of David, the means used include dreams Urim or prophets. 1 Samuel 28:6 How then was he able to hear the instruction involving the sound of the Lord's march?
We find the answer to the question in Exodus 25:22, "There above the cover between the two cherubim...I will meet with you and give you all my commands for the Israelites."
For those who believe in Jesus the Lord sets up the ark inside of the believer's heart. So the RTS (real time synchronization) in the area of the department of communication takes place "within" you.
In case of David (a believer) most likely he must have gotten the message (the strategy to go around and attack on hearing the sound of the Lord marching) in his inner sanctum built inside, and he must have gotten it in a dream at night.
But why is it that some are able to hear the Lord some don't?
Again we find the answer in Exodus 25:22. Consider the ark (communication system if you will) as a radio with different channels. To listen to a radio program you adjust antenna (if there is any), you tune in to the right channel and you hear the sound. When you are off you don't.
Why is someone off someone on in one's communication line with the Lord?
Study of the ark the Lord commanded Moses to build, and you will find why, noting that the Lord asked Moses to make the ark to get into a relationship with his children.
Even between husband and wife when the relationship goes sour the two cannot communicate. So the question of 'how' and 'why' goes to the issue of one's relationship with the Lord. Why does a relationship go sour? Begin with the Moses' Ten Commandments, for these are not just a set of do's and don'ts for nothing: The Lord gave the Israelites to build a working relationship with them.
The ark (containing the Ten Commandments placed underneath the atonement cover kept by two cherubim) put in the Holy of holies is the foreshadow of the realty to come, that is, our Lord Jesus Christ, the High Priest, the Prophet, and the King. When one repents turns to the Lord by faith in the Lord, one gets into the relationship with the Lord, so he can talk to, walk with, and live with Him daily.