I think it has to do with knowing precisely when to take jump, and perhaps he gets so excited when he is dunking that he hits the back of the hoop with the ball. Maybe he is thinking too much about the defenders, and not enough about the "hole".
He figured it out last night though, didn't he.