Because vaccines aren't always effective for everyone, and some people (e.g. immunocompromised individuals) can't get vaccines. But these people rely on herd immunity, which is depending on enough people being vaccinated that any disease that shows up isn't transmitted through the whole community. It's not the kids who don't get vaccinated that the legislators are worried about, it's everyone else.
And the rate of vaccinations in parts of California are so low that health officials are seeing the effects of lack of herd immunity.