What is the cause of frequent nightmares? Is there a reason why people dream of demons, ghosts, and other scary creatures? More specifically:

What factors cause frequent nightmares to occur?
Nightmares can be defined as (Pagel, 2000): 


  ...vivid and terrifying nocturnal episodes in which the dreamer is abruptly awakened from sleep. Typically, the dreamer wakes from REM sleep and is able to describe a detailed, associative, often bizarre dream plot. Usually, the dreamer has difficulty returning to sleep. 


Nightmares are common and can be a normal reaction to stress. Frequent occurrence of nightmares, however, may become a disorder when it impairs the sufferer's everyday life and may then be referred to as Nightmare Disorder (formerly Dream Anxiety Disorder) or "repeated nightmares," which is a term defined more specifically as a series of nightmares with a recurring theme (source: Psychology Today). 

Nightmare disorder is defined in the Diagnostic and Statistical Manual of Mental Disorders (DSM-5) as: 


  [R]epeated awakenings with recollection of terrifying dreams, usually
  involving threats to survival, safety or physical integrity.


Causes of nightmare disorder, according to WebMD, Psychology Today and (Sheaves et al., 2015) are:


Anxiety or stress, for example due to a major life event
Depression
Psychosis
Sleep deprivation 
Illness with a fever
Medication side effects
Drug or alcohol withdrawal
Excessive alcohol consumption
Sleep apnea, narcolepsy or restless legs syndrome or other sleep disorders
Eating just before going to bed, which raises the body's metabolism and brain activity


References
- Pagel, Am Fam Physician (2000); 61(7): 2037-42
- Sheaves et al., Can J Psychiatry (2015); 60(8): 354–61