Trek seems to treat the PD as a suggestion more than a hard and fast rule. We hear a lot about it's the highest law a starship Captain must obey, but right and left it gets violated and tossed in the trash for the sake of the story.Like in most situations involving non-members or primitive societies, the Federation decided what the best course of action for a society was without their input.
Which in this case is the sort of imperialistic bulls@#t the Prime Directive was supposed to put a stop to.
Until Star Trek Into Darkness when Kirk actually gets demoted for violating it.