When a crime is committed and you're arrested, your opportunity to defend yourself starts immediately. It's important that you don't say or do anything that can result in a conviction. That means not talking about what you were doing, trying to explain yourself or admitting to a crime in hopes that it will help your case.
Criminal cases go through a few phases. To start with, there is the arrest. This is when people should reach out to their attorneys so that they can have the situation assessed and receive information on what they should or should not say.
The district attorney reviews the case to decide if it's worth pursuing a criminal charge at this point. The attorney has to look at witness statements, prior criminal record information, traffic records and police reports to make this decision. Charges are then issued or declined, depending on the case. In the best-case scenario, this is when your charges would be dropped.
If charges are filed, then you will need to appear in court and be informed of the penalties, what the charges are and the rights you have. You'll have an opportunity to enter a plea for a misdemeanor case, but in felony cases, a preliminary hearing comes next. If the judge agrees that there is enough evidence at the preliminary hearing, you'll go on to arraignment for formal charges.
Your attorney is then in a position to negotiate a settlement and to help you defend yourself. Plea hearings and trials are possible at this point, so you need to become educated on the best ways to protect your interests.