It didn't, it's just very good at copying already existing code and tweeking it a bit.
>Did AI receive mentoring from an experienced senior
It doesnt even comprehend what an experienced senior is, all it cares about is how frequently certain patterns occurred in certain circumstances.
>Did the AI learn through hands-on coding or just by reading Stack Overflow?
it "learnt" by collecting a large database of existing code, most of which is very low quality open source proofs of concept, then spits out the bits that are probably related to a question.