Not Yoshi specific or shoe specific; just a matter of clanking hitboxes. Though I'm not sure about the rules of
priority in this game, generally stronger attacks beat out weaker ones. You can destroy some projectiles this way, or just beat out other attacks in general.
Hitting the cannonball is also just clanking hitboxes without getting hit, except it didn't beat out the projectile in this case. You get hit by a move if the hitbox overlaps with your hurtbox, but since Yoshi's dair is slightly disjointed(?), you can attack it without it overlapping with your hurtbox. Disjointed moves are usually explained with swords -- if you hit a cannonball with a sword, you're not gonna get hurt by the cannonball.
Though checking Yoshi's Smash 4 hitboxes, dair isn't that disjointed and I feel like there's another mechanic I don't really know about. For example, Pacman's hydrant (after it gets launched) might work similarly to Morton's cannonball, by basically being a constant hitbox, and there might've been a time before where attacking the hydrant temporarily disabled the hitbox...? That's speaking from memory and might not be accurate though, just bringing it up so that someone who knows more than me can add onto my explanation.