Whiff punishing has multiple layers/nuances, and is generally the entire crux of what Marth is all about, both against them and as them.
What you're looking at in a particular match up is how does the opponent extend when they attack.
Marth tends to extend out an arm in a vulnerable way during active frames, while Marth would tend to outrange or at the least, outdisjoint you, just about every character has more range than just his sword; so expecting or reading Marth's jump and forward air, you'd ideally be spacing to hit marth's extended hand.
Now if Marth doesn't fair immediately or retreats more than expected, they will feasibly be able to whiff punish your attempt to hit their hand. In the latter case as long as your spacing only entirely for their hand, then you likely won't be in danger of being swung at.
A common match up people bring up for Marth that's "difficult" or "losing" that I've never fully understood is DK/heavies (played against DK as Marth A LOT in the brawl days) is that marth gets outranged and then has issues in disadvantage state: gg.
When I'm playing neutral in those matchups, I'm not trying to hit my opponent where they stand/where I see them - I'm aiming my sword at their extending limb if they were to swing at me. In DK's case, as a non-animation power creeped character, even as his limbs have intangibility, after the active frames his arms are now vulnerable for multiple frames, leaving me in a situation of neutral where Marth/swords in general either win out or are still 'safe' from being whiff punished themselves.
When you read me ******** about animation-creep, a prime example is bayonetta's dtilt in s4 - her grounded sweep kick would swing entirely out of horizontal danger after hitboxes in TWO frames; thus making her almost entirely immune to whiff punishing due to how much range/how strong the hitboxes were on top of it.
Compare to Zero Suit, who was the 'base' template character used for Bayonetta, who would otherwise do the exact same down tilt sweep yet her leg would remain horizontally vulnerable for FIVE frames. It also had close to 20 frames more end lag than bayo's to boot.
Zero Suit's back air did what bayo's dtilt did in s4 too, but i felt was a lot more saner thing considering the precision requirements and the conditions of being in the air/etc, but essentially her roundhouse kick leg would be back in the fore/background in two frames, and as it came from the z-axis, was an ideal whiff punishing tool. In ultimate they nerfed the animation so her leg freezes and stays vulnerable for 2 extra frames.
I guess in an attempt to be succinct, whiff punishing for me is generally about being able to read/anticipate an opponent's action and attack from beyond their reach, which generally would be further away than where that character's "standing" and neutral stance would be.
A natural way to work towards this is to consider an opponent's shield: it extends a hurtbox usually a fair bit ahead of them at it's extremes; if you aim to space perfectly on shields you tend to be at a good spacing for dealing with body extensions from attacks too (and are then also generally entirely immune to immediate OoS options of anyone).