The design of the legal system in the United States means there are multiple levels. The highest level is the federal government, which has jurisdiction over the whole country. The next is the state level, which handles matters within the state boundaries.
Each level has overlap when it comes to crime. For example, murder is illegal at all levels. Typically, the charges come from only one level. Deciding whether the state or federal courts handle a case depends on the circumstances.
Sometimes, the court handling the charges depends on who the victim is. For example, any crime against a federal official will typically go to federal court. If the federal government is a victim, it also will handle the prosecution.
The location of a crime may also impact which court handles the case. For example, kidnapping is a crime at the federal and state level. Many times, states will handle these cases, but the federal government may step in if the crime involves multiple states. This can happen with many crimes where some aspect occurs in two or more states. For example, if a serial killer is operating in multiple states, each state will usually handle the murders occurring in its jurisdiction, but if the killer commits a murder that crosses state lines, the federal government may step in.
Of course, the law is ultimately the deciding point. If a crime occurs and there is no federal law against it, then the state would handle it. The only time federal agents get involved is when a federal law is broken.
Prosecutors at each level have the ultimate decision on whether to handle a case or not. It is common for officials at one level to decide not to prosecute a case, but then officials at the other level pick it up.