Here on HN we often see posts insisting on the importance of "first principles".
Your embrace of "magic" - an unknown black box who does seemingly wonderful things that usually blow up to one's face and have a hidden cost - is the opposite of that.
LLMs are just text prediction. That's what they are.
>Why can LLMs generally write code that even compiles?
Why can I copy-paste code and it compiles?
Try to use LLM on code there is little training material about - for example PowerQuery or Excel - and you will see it bullshit and fail - even Microsoft's own LLM.