He's 4.
Simple "mistake."
He was not trying to be mean or callous, I am sure. (?)
But the long-haired boy's Mom, was upset.
So you/the Teacher talked to your son about it.
Fine.
But besides telling your son "don't do that anymore...." I would have explained to him, that boys also have long hair. Even grown men, may have long hair. It does not mean they are a "girl."
I told my kids that when they were Toddlers.
No big deal.
And even boys or grown up men, have earrings too.
Its just doo-dads.
Not a gender thing.
My kids know that.
At school, both my kids have classmates, boys, that have LONG hair. No biggie. No one makes fun of them. Everyone knows they are a boy.
Some girls also have SHORT hair. It does not make them a "boy."
Its just, hair.
The Surfers here, even the kid surfers, they often have long hair. Lovely long surfer hair! And its no big deal.
You said that that long-haired boy, is your son's friend.
But if he is calling that boy a "girl" in order to "tease" him..... then that, is, rude. And uncalled for.
As far as the Mom being upset about it, well, being her son has long hair, she may encounter her son's long hair confusing other kids in the future. But that is their, personal choice, to have the son have long hair. Or not.