Mental health is a large part of the issue, but sometimes cause and effect can be murky.
It's important to note that even the very large visible encampments in cities like SF and LA are the tip of the homelessness iceberg, there's a much larger group of people who are living on friends/relatives couches, in their cars, or in shelters. A lot of these people have some level of employment, but housing affordability (a result of ~50 years of very restrictive land-use policies making it hard to build new housing) means that this level of employment can't afford them their own permanent home. For example, prior to 1970 it was much more common to see "boarding houses" where you'd share a room or share a bathroom, and especially unmarried low-wage workers would live there, but these are illegal to build in most cities these days.
Most of this homeless-but-not-on-the-street population is transient - it is common eg to be temporarily living in your car after a job disruption or sudden emergency expense, then to find another job and find a place to live after some time. In other words, they will do exactly what you are suggesting and lock down a new job quickly. And this group is a majority of the group of people who spend any time homeless in a given year.
But a portion of of this transiently-homeless population doesn't solve their job situation quickly, will wear out their welcome with friends, or will lose their car for a variety of reasons -- and end up falling into street homelessness. Once you are homeless and living on the street, you are at extremely high risk for developing a mental health and/or substance abuse problem even if you didn't start out with one. It also becomes much harder for you to get one of those available jobs, for a number of reasons, some as basic as not having transportation to work or not being able to present yourself well for an interview.
In short: land-use policies cause homelessness, the majority of the people who experience any amount of homelessness do get a job quickly, the street-homeless you see are the small fraction (of the frighteningly-large homeless population) that got stuck for some reason, and their situation is a feedback loop making them even more stuck.
(also: the 'we will hire you on the spot!' thing is a weird 2021 artifact of the pandemic, it taking time to ramp back up, and the super-generous unemployment benefits program that will be expiring very soon. the hiring market won't be like that next year)