Phobias usually grow from a mix of factors: inherited temperament (some people are more prone to anxiety), direct frightening experiences, watching someone else react fearfully, and information like warnings or stories. Two people who had the same scare can end up with very different responses, because how strongly each person's brain links a cue with danger depends on their personality and history.
Learning theory explains much of the variation: a fear gets stuck when a neutral thing (a dog, an elevator) is repeatedly paired with a threat, and avoiding it then prevents the fear from ever being corrected. Psychologists also note that many people with phobias can't recall a specific traumatic event, so the origin is often more gradual or indirect than a single dramatic moment.