Basically the two main things to do are:
1) be intimately familiar with the range on all your characters' moves
2) get better at moving around with your character(s)
A lot of this can just come from raw experience. You'll eventually get a feel for and become comfortable with doing these things the more you play. But for some more specific, training-room sort of things (at least for the first one), go into training mode and just try to hit an idle training dummy CPU with each of your moves. Start farther away than necessary, then inch your way forward until the attack hits the dummy. This way, you'll at least have some idea of your moves' maximum range.
I'm not really sure what to tell you though for getting better at moving around other than "practice moving around", which is not exactly the most helpful thing to say, but it just seems to me like one of those things that you just get accustomed to over time.
Something important to keep in mind though is that no one can space perfectly all the time (if anyone could, Marth would be god). It's actually a two person thing, and one that not only varies for each character, but for each matchup too. Where each character wants to be relative to their opponent at any given time depends on the character, and who they're facing. It's a constant battle of the two people trying to position themselves favorably as best they can.
.....I, uh, hope this is of some use at least anyway