Although nightmares, and dreams in general, usually have no specific reason whatsoever, there are medical and scientific theories as to why they may happen.
- Not getting enough sleep: When your body and brain do not get the rest they require (including REM sleep), nightmares may occur when you actually do sleep. Any lack of sleep can cause this including sleep disorders such as sleep apnea and RLS.
- Stress and anxiety: Constant thoughts about problems in life can cause you to have nightmares. This can be current stress and anxiety or past stress and anxiety, including PTSD.
- Eating late: Eating increases metabolism and may, therefore, increase the rate at which the brain works when it should be resting.
- Medication: Some medications cause nightmares. Most of these medications are prescribed to change the chemical makeup in the brain already such as antidepressants and antipsychotics.
- Withdrawal: Withdrawal from any addicting drug (including nicotine and alcohol) can trigger many different psychological side-effects, including nightmares.
The following link may help you better understand and cope with your nightmares:
https://www.psychologytoday.com/conditions/nightmares