Maybe the statistical approximate just coincidentally lined up with the actual solution?
Yes, right, and this can happen. I didn't say they are a bad approximation. LLMs may be the most advanced and sophisticated statistical models ever created (if there are other examples of statistical models that are more sophisticated, I would love to learn about them). But given what an LLM actually objectively is, a statistical model of the next token to follow from a sample of language, what other explanation could there be?
We need to keep in mind what the tools that we are working with actually are.
As a code generator, they can produce great results, especially simple stuff like generating a script or some function implementation. Once you get to software engineering tasks like designing system architecture and designing maintainable code, it starts to fall apart really fast. You end up doing all of the work for it in natural language and just using the LLM for a usecase that it is actually great for: translation, from detailed spec to code.