If you are accused of a crime, the only person that can help you out is a criminal defense attorney. This is because you are not familiar with how the judiciary system works which makes it hard for you to represent yourself in open court.
This is because a lot of the legal rules are hidden away in court interpretations of federal and state constitutions. A good example is whether or not the search of your home was reasonable. It can only be considered a good search if the police obtained a warrant otherwise anything found is not admissible in court.
Given that the criminal defense lawyer has crossed swords with the prosecution in the past, they are already familiar with the tactics that the opposing party will be using and be prepared for it.