Spacing means a bunch of different things. It can mean hitting with the tip of your attacks, or just simply dancing out of your opponent's attack range and waiting for an opening. In general, though, spacing just means being out of range from your opponent's attacks, and in many cases using one of your moves to dissuade your opponent from following you. You can space while being on the offensive, though. A GnW can space by using a retreating Bair to keep himself from being shieldgrabbed upon landing, or to simply spam it and keep his opponent at bay. Marth is the most common example of spacing, due to his attacks requiring a "tipper" in order to be most effective. Marth outranges most characters due to his gigantic blade, and can thus approach or retreat with his large Fair. Fair's tipper generally outranges most aerial attacks in the game, and thus by approaching and hitting with the end of it, he's keeping himself out of harm's way.
In other words, a Marth with good spacing will hit with the tip of his Fair and thus avoid retaliation by most characters, even if he hits a shield in most cases.
However, a Marth with worse spacing may hit with the center of the blade while approaching. This allows him to be hit by other character's attacks and get beaten out from their attack hitting first, or he may hit a shield and get shieldgrabbed due to being so close to his opponent.