In order to detain you, the police are supposed to have a reasonable suspicion that you're involved in a crime. For example, if an officer stops and individual, it would not be enough for the officer to be thinking, "He looked like he was up to something." The officer's thoughts would have to be more specific, such as, "He kept looking in the window of the jewelry store, then walking away, then coming back and peering into the same store again. And he wasn't from the neighborhood. He seemed nervous and agitated, so I thought he might be planning a burglary."
Usually, a reasonable suspicion is based on multiple factors, such as: the suspect matches the description of a wanted criminal; the suspect drops an object after seeing the police; the suspect runs away after seeing the police; etc.
Detention is supposed to last only a short time (approximately 30 minutes) and should not involve changing location, such as going to the local police station.
It may be useful later on, when you're fighting the case in court, to have asked the officer why you're being held. If the officer cannot articulate his suspicion, you may be able to show that your detention was unlawful. Obviously, this tactic works better if you have witnesses who will testify that the officer made an inadequate reply. (Without witnesses, it's just your word against the police officer's, if the officer lies about what he said.)