Know Your Rights
Every hacker out there (unless of course, you're an absolutely pure white hat hacker) has probably worried at one point or another about being questioned and taken into police custody. This is assuming that you've already been caught, and you are currently at the police station.
The police have two choices now: If they tell you your Miranda rights, then they have to provide a lawyer for you if you ask, and you have the right to say nothing. Their other option is to not tell you your Miranda rights, and give you the right to walk out of there whenever you want to. If you are not told your Miranda rights, then it is simply an interview, and you are not under arrest or in any type of trouble (officially).
One way to find out which path they're going to take is to just simply ask "Is this an interview, and am I free to leave?" This will make them either give you a lawyer (or a right to one if you can afford one) or they will have to let you walk out of there.
Now suppose that you've forgotten the previous paragraphs, and start talking, which you never want to do. Just stay silent, and it'll be better for you (there is no "most of the time", it will ALWAYS be better for you if you stay silent)
Another way the police might try to make you give a statement is to talk you into it, by saying that it'll just be easier if you give a statement. NEVER agree to this, because that "statement" you sign is admissible in court as a confession, so you're just handing a gun to the people who want to kill you. Keep in mind that your right to remain silent extends to written statements as well, so writing something down for them is also a big no-no.
If they are recording your interview, and you ask them to turn off the video camera, the voice recorder, or what ever it is they're using, remember that their notes they take are also admissible as evidence, meaning that if you give a confession to them, and all they have to back up your confession are notes, then the confession still holds.
Assume you're forced to take a polygraph test. First off, you have the right to remain silent, so don't sign the waiver saying you are knowingly allowing them to ask you questions by which you might be incriminated. Secondly, the police/authorities/prosecution might trick you into thinking that the polygraph will help you prove your innocence. Don't believe them, because even if you think you can trick the machine by controlling "uncontrollable" events, like your heart beat, you're going to let something slip. Also, since there are a lot of different variables being monitored, chances are very high that something will change when you're being questioned.
During questioning, even if they're (they being police/prosecution) not using a polygraph machine, there are ways of detecting lies. The first is CHANGE. Your eye might start twitching, you might start breathing faster, it doesn't matter what, but something will CHANGE. Also, when you are being questioned, look up and to the right, and NEVER up and to the left, because looking up and to the right will correspond with remembering something, up and to the left means that you're making stuff up. Even if you're one of the few that look up and to the left while remembering facts, it will be perceived as lying.
In addition, if they want to search/seize your computer or other property, they MUST have a search and seizure warrant unless you willingly let them search it. Ask if they have a warrant before you let them take anything.
There are other rights that you have, but they are kind of obvious, and it would take forever to list them all, these are just a couple of the less obvious and more useful ones.
Most importantly however, (assuming that you've already done something illegal and that you've already been brought to the police station) is to stay silent, ask for a lawyer, and don't sign (verbally, in writing, or in any other form of communication) the waiver saying that you are willing giving up your right against self- incrimination. If they don't read you your rights, and start questioning you, ask if you have the right to leave.