Criticism about the effective application of the Prime Directive in Star Trek stories goes back to The Original Series and every iteration has a few episodes that gloss over, overlook, forget, or simply ignore the Prime Directive for the sake of story continuity.
In the case of the Next Generation episode Justice, in which the Edo appear Wikipedia indicates:
In contrast, the Next Generation episode "Justice" did not explicitly
explain whether the Edo people were pre-warp or were aware of offworld
space travelers prior to the Enterprise's visit. If the case is the
former, then when Wesley Crusher is sentenced to death, the violation
of the Prime Directive had already occurred and the issue of rescuing
him, while politically exacerbating matters, might not have been a
violation of the Directive.
Emphasis is mine.
Violations of the Prime Directive are numerous and recounted in the Prime Directive entry in Wikipedia:
One criticism regarding the Prime Directive is that it is
inconsistently applied, depending on a planet's strategic importance
or the circumstances in which a starship crew finds itself. For
example, as part of the Federation's then-ongoing hostilities with the
Klingons, Captain Kirk was ordered to make contact with the seemingly
pre-industrial Organians in "Errand of Mercy." In addition, Kirk
directly interfered with the laws or customs of alien worlds in
"Friday's Child," "For the World Is Hollow and I Have Touched the
Sky," "The Cloud Minders," "The Apple," "The Return of the Archons,"
and "A Taste of Armageddon," in order to achieve a Federation
objective, to save the lives of his crew, or both.
Compounding matters is that in the TOS episode "The Omega Glory," Kirk
states, "A star captain's most solemn oath is that he will give his
life, even his entire crew, rather than violate the Prime Directive,"
and yet he seemingly violates the Prime Directive as "the only way to
save my ship" in "A Taste of Armageddon" and no explanation for the
Federation Ambassador trying to mediate between Eminiar VII and
Vendikar (neither of which are Federation members) regardless of their
wishes on the matter is given.
In "The Return of the Archons" and "The Apple" reference to the "Prime
Directive of non-interference" is made by Spock. In "The Return Of The
Archons," Kirk says the Prime Directive refers to "a living, growing
culture" to justify interfering with what he sees as the
non-development of the computer-controlled culture, asking pointedly
in reference to it, by contrasting it with living, growing cultures,
"Do you think this one is?" In the "The Apple" Spock points out that
Starfleet Command may not agree with his choice to interfere with the
computer controlled culture to which Kirk replies "I'll take my
There are also episodes in which the Prime Directive should have been
mentioned, but wasn't. In "The Paradise Syndrome"," the Enterprise
attempts to save a pre-industrial planet by moving an asteroid that
was on a collision course with it; when McCoy asks Kirk if he should
warn the people, Kirk and Spock only point out the people would not
understand the warning, and neither makes any reference to the Prime
Directive. In "The Cloud Minders Kirk interferes with the culture of
Ardana to obtain zenite the only cure for a biological plague ravaging
Admiral Matthew Dougherty's reasons for violation of the Prime
Directive in Star Trek: Insurrection in Picard's time echoes the
reasons Kirk gives McCoy in "Private Little War" but Picard considers
them invalid. In "Homeward," Nikolai Rozhenko (Paul Sorvino) uses
holodeck technology to save the Boraalan and enforce what he believes
is the spirit of the Prime Directive even though Picard has already
said such actions violate what it actually states. In "Pen Pals,"
Captain Picard rectifies contact with an inhabitant of a pre-warp
planet by ordering her memory erased. When contamination became too
serious to be fixed by memory erasures, Captain Picard decided to make
direct contact with a civilization's leaders in "Who Watches the
Watchers" and "First Contact," although the latter episode involved a
planet on the verge of achieving warp flight, and therefore eligible
for First Contact. Finally, in "Natural Law," the Voyager crew took
measures to ensure the protected isolation of a primitive people, even
from a more advanced civilization who share the same planet.