The Prime Directive, aka General Order One, states that: "No starship may interfere with the normal development of any alien life or society."
That has often been translated in the facts as forbidding contact with any civilisation unable to reach the stars by themselves, with the possession of working warp technology used as the tipping point, as explained in First Contact (TNG S04E15).
(Mirasta is punching buttons when two figures beam in)
PICARD: Mirasta Yale?
MIRASTA: Yes.
TROI: Please, don't be alarmed at our appearance.
PICARD: My name is Jean-Luc Picard. This is my associate Deanna Troi.
MIRASTA: What are you?
TROI: We've come with some important information.
MIRASTA: About what?
PICARD: About space. About the universe you are preparing to enter.
TROI: We come from a federation of planets. Captain Picard is from a planet called Earth, which is over two thousand light years from here. I'm from another planet called Betazed.
PICARD: We've been monitoring your progress toward warp-drive capability. When a society reaches your level of technology and is clearly about to initiate warp travel, we feel the time is right for first contact. We prefer meeting like this, rather than a random confrontation in deep space.
TROI: We've come to you first because you're a leader in the scientific community. Scientists generally accept our arrival more easily than others.
PICARD: We almost always encounter shock and fear on this sort of mission. We hope that you will help us facilitate our introduction.
MIRASTA: Is this a joke? Did Lupo and the others from the lab put you up to this?
PICARD: It's certainly no joke. As you can see, we are physically quite different from Malcorians. And, with your permission, I'm prepared to prove it to you.
MIRASTA: I would like that.
PICARD: Picard to Enterprise. Three to beam up.
The episode also seems to imply that the Federation usually waits after the first successful trip into warp before establishing contact, but they decided not to wait in this case due to the disappearance of Commander Riker and the assurance by Chief Engineer LaForge that the Malcorian warp drive would work.
However, StarFleet and the Federation have established contact with many pre-warp societies and civilization that had already been exposed to the galaxy at large through other means, like the Bendii in Farpoint (TNG S01E01).
The Bendii were clearly lacking the technology to reach the stars by themselves, but they had been contacted by other spacefaring species, their leader cites the Ferengis when negotiating with Picard, thus why the Federation established contact with them and looked at their proposal to establish a starbase on their planet.
A civilization/society/species that has access to the galaxy by any means is already seeing it's development altered by exposure to ideas, technologies and cultures from other races, thus establishing contact with them is authorized as it wouldn't interfere with their normal development.