to understand spacing, you have to understand that the positioning of both characters determines what options are more viable/less viable to each player.
having good spacing essentially means that you know enough about the game to make decisions based on positioning. although this next thing is an oversimplification that can encourage you to space mindlessly and not think about anything else, it sometimes helps to break it down into good ranges and bad ranges for each character.
for example, let's look at marth vs fox. whenever fox is INSIDE marth's sword range, it's definitely good for fox. he can shine and do a bunch of other silly nonsense </hate fox> and marth is able to.... block, grab, swing pathetically (since all of marth's ground moves are weak as **** at close range), or get the **** away (or some combination of these). whenever marth is at full sword range, he has his entire array available to him, pretty much, and it's all (relatively) safe to use..... and since nobody else in the game has marth's range (except ganondorf, to an extent), this would be a good range for marth. fox, on the other hand, has a good range right outside of marth's sword because at that range, he has his running shffl nair (and dash attack, among other things) available to him, and there's not much that marth can do except take risky swings hoping fox is going to run into it. if you are in a bad range, you still have options, but they're limited in one way or another. for example, if fox is right outside marth's range, there's nothing in the game's code STOPPING marth from moving up and trying to hit fox....
well, now that we've gone over looking at ranges themselves, we can talk about how they come into play. smash is a ridiculously dynamic game with really quick movement and tons of possibilities, so movement, prediction, tricking your opponent, covering multiple options with prediction/reaction, understanding minute details about a situation, knowing obscure situational options for each range, and a bunch of other things are how you play around these ranges being the be-all, end-all of the game.
movement in smash accomplishes a lot of things. for example, one of the first things that separates a competitive noob from a COMPLETE noob is understanding how dashdancing can be used as bait. put very simply, when you dash at your opponent at a certain range, it makes it look like you're going to run at them. this gets them scared and makes them want to swing. if they swing and miss (or if they swing and hit your shield at a certain spacing), then they will be in punishable lag. if they are in punishable lag.... well, punish them. if they DON'T SWING and keep moving around instead, then you're able to advance on them by committing to attacking them or by simply continuing to move aggressively until you push them to the edge (literally and figuratively). you can either keep pushing until they're trapped by the stage's edge, or you can push them to sanity's edge until they do something stupid that you can punish.
everyone that plays this game with the smallest iota of seriousness understands this previous paragraph to some degree, whether they realize it or not. a lot of smash skill is/can be subconscious and intuitive.
as i said, this is what separates a competitive noob from a COMPLETE noob.... so how do you get better than other people who also understand this? there are so many ways to gain advantages over other players that i don't even want to explain it, really. you just have to play the game a lot and learn more about it. for example, understanding minute details in the neutral game, having a good understanding of player/character tendencies, being experienced enough to make decisions naturally and react quickly, having better mechanics than your opponent, and tons upon tons upon tons upon tons more.
this may sound like waaaayyyy too much work to be putting into a video game.
my rebuttal? it is. the price and reward of learning to play smash at a competitive level is definitely not worth it on paper, but i still don't regret it one bit.
why? it's not all about the game itself. it's about the experiences i've encountered from playing this game. these past five and a half years have been a hell of a ride, and it doesn't look like it's stopping anytime soon. i've had so many unforgettable experiences, met a metric ****ton of amazing people, been a part of a fun and lively community that spans across multiple continents, traveled to other states, learned a lot about myself and about life, and grew SOOOOOOOO MUCH as a person. keep in mind, MOST OF THIS was while being a high school student who still lived with his parents.... and i was able to do ALL OF THIS while being able to have fun with my favorite game in the world.
thanks for reading. and if you're interested in taking this game more seriously (whether you want to legitimately become a top dog or if you just want to pick up a few video game skillz for fun), may the odds be ever in your favor.