Actually this isn't the whole picture. Because a lot of funding for schools comes from local property taxes, affluent areas tend to have more resources for education than poorer areas, regardless of how they school their kids. And if a lot of higher income students aren't utilizing public school, that's less students to spend the increased money on, which would exacerbate the view when looked at as a national per-student average.
Still, poor students in california do dramatically worse than poor students in mississippi, despite california spending much more. I dove into the data a while back and adjusted for income and race, California schooling is much worse and only looks good because its students are rich
Mississippi cooks the stats by holding the poorest students back. You can probably adjust for this if you have the raw data, but it's something you need to adjust for.
If you didn't let students into the 4th grade until they were 40 inches tall, you'd have taller than average 4th graders, but only because of survivorship bias.