The writ of habeas corpus applies to detention, not prosecution. In fact this is why it exists. If it only applied after a crime was alleged, the government could hold people in extrajudicial detention forever so long as it never leveled criminal charges. The Bush administration did exactly that in Guantanamo and was slapped down by the Supreme Court.