It's generating millions of permutations of the next token. Not the entire program, how many complete responses it generates depends on the internal workings of the full program not just the model. But as I stated elsewhere the core of the LLM specifically is a heavily capped, parallelized brute-force search across discrete token spaces, sequence branches, and reasoning paths that relies on exhaustive evaluation within strict mathematical caps.
Now I am open to hear how you interpret it differently, but the I don't think it's possible to abstract it away from a guess and test approach at the most basic level.
I think you may be making a similar faulty argument to this one here: https://news.ycombinator.com/item?id=50650085
I'm also confused what you think human software engineers do when they write programs. Don't you also test what you write and iterate on any errors?