Not all veterans become homeless but they are 50% more likely to. There's many reasons for this. Some veterans find themselves struggling with substance abuse, whether alcohol or drug related, which often starts during their time in the military or shortly after. Alcohol use in the military is fairly high and can easily be used as a coping mechanism when leaving the service to deal with things like PTSD, alienation from family/friends back home, depression and anxiety. Leaving the military is not an easy thing for some.
Sometimes when veterans get out of the military they don't have a good support network so often they'll find themselves struggling to find work and may end up living in poverty or other dismal living conditions like overcrowded/substandard housing. Social isolation and lack of support are key factors for those who end up homeless after the service.
Your housing is only provided when you're actually in the military. College benefits have not always been afforded to veterans and even today many don't take advantage of things like the GI Bill. But even if they do it's far from guaranteeing you won't end up homeless due to the other factors I talked about (social alienation, no support networks, mental issues, financial problems, etc.) And of course you're paid while you're in the military but you don't get paid after you're done unless you're collecting a pension, disability, etc.
The VA has often been a contributing reason many veterans may end up homeless. Lengthy wait times, denial of proper disability payment, poor medical treatment and sometimes straight up neglect leaves many veterans paying for service related injuries out of pocket or not even being able to pay for them at all. However the VA is not always an issue and many veterans can find themselves receiving proper care.
There's no single deciding factor as to why some veterans become homeless - there's a plethora of reasons, some service related and some not. Some could have been prevented and some could have not.