The malach teaches the child the Torah in the mothers womb and then he forgets it. This shows that he has the ability to learn it. I heard a logic that the child is in aveilus (not cuting hair) for forgetting the Torah, so they don’t cut it until he can learn Torah again at age three when he can start talking clearly.
The makor has little to do with the minhag. The Shaarei Teshuva mentions (I think Misha Berura chelek gimmel) that the Ari Z”L’s son went to the kever RASHBI on Lab B’Omer to give his son his first haircut.
Somehow that turned into “No haircuts until three then a big party”.