Parent is right. We know mechanically how LLMs are trained and used but why they work as well as they do is very much not known.
Sorry, but that's reductionism. We don't know how human brain works, and that you won't get there by studying quantum electrodynamics.
LLMs are insanely complex systems and their emergent behavior is not explained by the algorithm alone.
You may want to take a course in machine learning and read a few papers.