The funding for the original institutions came from the Community Mental Health Act (CMHCA).
The funding for the alternatives was also slated to come from the federal government: https://en.wikipedia.org/wiki/Mental_Health_Systems_Act_of_1...
But Reagan and a Republican controlled Senate killed it. Because funding was supposed to magically "trickle down" from thin air.
And, through it all, the mental health facilities were always chronically underfunded.
The emptying of institutions in California happened long before that, in the late 60s and through the 70s; it became very hard to commit anyone, which justified further cuts.
If you pass a bill that destroys mental health systems for the sake of civil libertarian concerns, "its issues weren't magically fixed through half a century later, which was totally unforeseeable" is not a good excuse.