Let's see if I can put some light on your confusion.
The Prime Directive states that the Federation is not allowed to interfere in the natural development of a species.
For the most part this means you cannot give a pre-warp species advanced technology, introduce them to alien life forms, nor influence their socio-political or cultural advancement (or lack thereof).
Now, several planets appear to have been "grandfathered" in before the development of the Prime Directive (Eminiar, from "A Taste of Armageddon," for example), and apparently had diplomatic relations with the Federation at some point, despite being a pre-warp culture.
It's also apparent that Starfleet was more lenient on possible PD violations during the great expansion of the mid-to-late 23rd Century.
Davy Jones
"Frightened? My dear, you are looking at a man who has laughed in the face of death, sneered at doom, and chuckled at catastrophe! I was petrified."
-- The Wizard of Oz