Most often, dreams are simply a composite of thoughts and feelings, and don't mean much. Recurring dreams are another matter, likely a subconscious expression of anxiety concerning some particular issue.
Then there are dreams from God. Certainly very rare, but they do happen. Some may have had dreams from God but haven't yet recognized them as such. These dreams aren't usually understood initially, and are almost always metaphorical. The meanings are generally revealed at some later point in time, to serve as confirmations of spiritual principles and paths.
There is another category: dreams from devils. These aren't necessarily nightmares, though they can be. My guess is most of the time they're intended to deceive those who have given themselves over to some kind of wickedness:
"The coming of the lawless one will be accompanied by the working of Satan, with every kind of power, sign, and false wonder, and with every wicked deception directed against those who are perishing, because they refused the love of the truth that would have saved them. For this reason, God will send them a powerful delusion so that they will believe the lie, in order that judgment will come upon all who have disbelieved the truth and delighted in wickedness." (2 Thessalonians 2:9-13)
Only by the grace of God can one know the difference.