Greets,
If you're playing against the AI, remember that they're expanding as well so you don't need to stop and fortify at two planets to survive. Get a couple of scouts auto-exploring first, then get your first (free) cap ship built. Once that's done you should have a good idea of your surroundings and the layout of the planets near you.
All thats left to do review the layout of the planets, and make a beeline for those that are suitable to form your front line and begin to make choke points (usually two on smaller maps). Once they're established, you're safe to work backwards towards your own home planet and begin fortifying your frontiers. The AI won't jump through those choke points unless they exterminate the colony first - at least not with anything thats a threat.
Keeping the pirates off you for the first few runs is pretty easy. Just bribe away. Once you know where their base is, you know where they're going to attack you (the closest planet to their base which should be one of your fortified front line planets by this point).
Aim higher

Two or three planets isn't really enough to get a decent economy going. If you don't go get them, the AI will. Try creating those choke points by grabbing 5-6 planets right off the bat on a small map. It should put you in good standing and then allow you to settle down a bit after initial expansion and start hitting that research tree in a serious way.
Not perfect, but it should get you started winning/surviving against the AI.
Good luck mate,
Mopy
::Edit - Yes for turning off pirates. Update to the latest patch and you can turn them off