Various things can cause phobias.
It can be because a phobia was learned in early childhood, either from actual experiences that stuck with us or from seeing adults around us acting with fear toward certain things. Someone I know has a severe phobia of snakes, and this is because she grew up in a rural area and the house she lived in when she was little was often invaded by poisonous snakes. So she was constantly worried about stepping on a snake or finding one in her personal space that could harm her. Her parents were always drumming it into her mind that she must constantly check for snakes and watch where she walks. She is an adult now and lives somewhere you don't get snakes, but she still has nightmares about them. It has become a phobia for her. Even seeing images of snakes upsets her. She got angry at me once because I showed her a picture of a snake that I thought was beautiful. I wasn't aware at the time how traumatised she was, else I would never have showed her the picture.
Certain phobias can also be a result of traumatic experiences in previosu lifetimes. For example, severe and unexplained phobia of water can mean someone drowned in a previous life. That memory is still imprinted on the soul.
Another angle is to look at it from is the perspective of ancestral trauma. This is the belief that we inherit more than just physical traits from our ancestors and we can actually inherit some of their life experiences. In this sense, some phobias could be a result of traumatic experiences our ancestors had. This is called epigenetics.