We're not exactly sure of what is occurring in the programming, but it has to do with the attack animation ending right before Link hits the ground. If Link is "touching" the ground as his attack animation ends, he can do another midair jump (although it is almost the exact same as if you jumped from the ground).
This is extremely easy to learn using Bowser's sideB. If you do his sideB in the middle of a jump, and he is still in the animation before he touches the ground, you can easily do another midair jump, sideB as you approach the ground, and then sideB infinitely. All you need is to be "touching" the ground as the animation ends.