Yes, you can develop hallucinations for a variety of reasons. No one is born having hallucinations, and they typically develop in people in their late teens to early twenties, though they can develop before or after that period.
The most commonly-known reason is a schizophrenia-spectrum disorder. These disorders have a genetic factor that is then influenced by epigenetic and environmental factors. Typically, these disorders are preceded by sleep disturbance, and the hallucinations and/or delusions
in frequency, duration, and intensity over the first few years.
Hallucinations can also develop in disorders such as borderline personality disorder, bipolar (during a manic episode or depressive episode), psychotic depression, and sometimes PTSD or extreme anxiety.
It is also possible to have a singular episode of a hallucination or delusion without it being indicative of any disorder. This is particularly true in grief, but can occur other times.
Drugs can also be hallucinogenic. Certain drugs, such as LSD, can contribute to the emergence of latent psychotic disorders.
Best of luck.
Edited: I added bpd to possible causes of hallucinations. This is by no means an exhaustive list, though.