IT SOUNDS like a great whodunit. A phantom attacks some 170 people, killing 29. The whole state is frightened. Detectives pursue countless theories and clues, but to no avail. Congressional kibitzers berate the police, charging that their ineptitude may be allowing a madman to run loose. Then, months later, a team of dogged investigators quietly puts the pieces together and cracks the case.

That's about how things have gone in the hunt for the cause of "Legionnaires' disease," the bizarre epidemic that struck so savagely in Philadelphia last July. After ruling out hundreds of suspects, from various viruses to poison gas, scientists at the federal Center for Disease Control in Atlanta think they have finally found the culprit. It is not a man but a microbe - an odd, unnamed bacterium that also appears linked to a pneumonia outbreak that killed eight people at St. Elizabeths Hospital here in 1965.

As in many such cases, CDC's detectives happened on the bacterium in the course of exhaustive tests for something else. After finding the strange microbe, they amassed their evidence through the medical counterpart of ballistics tests. The ties to the St. E's epidemic, a long-unsolved case, could be found because, like all first-class detectives, the CDC's analysts have kept excellent files - in this instance, samples of blood sera that had been in CDC's deep-freeze for 11 years.

Though the evidence is already rather impressive, the case against the bacterium is still being built. Moreover, the medical detectives have not yet figured out where the deadly microbes came from or how they were spread. So the case is still very much open. Indeed, it may never be settled conclusively enough to satisfy all of the critics and conspiracy-hunters who have gotten involved. The latest announcement shows, however, that congressional press releases are much less productive than patient, careful research.