There are a few different ways that something can qualify as a federal crime instead of a state crime. For example, if the U.S. Constitution has been violated, or if the crime specifically violated federal laws and not state laws, then federal courts have jurisdiction. This is also true when government entities are involved. A crime committed against the IRS or the U.S. Postal Service is a federal crime, for example.
One thing to keep in mind is that crimes are often tried at the federal level if they cross state lines. If the crime happens in only one state, then that state may have jurisdiction if an arrest is made. But when multiple states are involved, rather than having separate trials on both sides of the state line, the federal government has jurisdiction.
How would this happen?
This often happens with crimes that involve travel, such as drug trafficking or human trafficking. If there is continuous involvement in criminal activity from one state to the next, then it may be a federal crime. But when two separate crimes are committed, one in each state, then they both may be processed as state crimes in their respective jurisdictions.
Things can get complicated with white-collar crimes, which often rely upon technology. For example, say that two people are accused of working together to run an investment scheme. They get investors from all across the United States. This likely makes it a federal crime, even if the two people never travel outside their home state. The crime still extends over state lines, even if those communications are digital and made via the internet.
These types of cases can be very complex, so those facing charges need to know what defense options they have.