One may convert a compelling interest in getting a parent's attention into a drive to do well in school. Sexual drives can be pored into sports. Anger and resentment of the advantages of others can be funneled into an obsession to excel in a lucrative career. Actually, we often benefit by rehearsing in fantasy for future successes. At other times, fantasies may provide a way to express feelings we need to get off our chest.
Fantasy is only a defense when it is an escape.
Anticipation of the future through fantasy is a mark of an intelligent species. If fantasies can be therapeutic, then they can be harmful, e.g. imagining awful consequences could create fears, sad thoughts may produce depression, reliving an insult in fantasy might build anger. Fantasy may be part of the problem or part of the solution. Alfred Adler, a free-thinking student of Freud, observed that feelings of weakness and inferiority are common when we are young. Much of life, he thought, was devoted to compensating for our real or imaginary weaknesses, i.e. striving for superiority.