You never have to talk to government [whether you are a suspect or a mere witness], except on the witness stand after having been properly subpoenaed, and hence you should not. You should not talk to the cops; you should not talk to prosecutors or DA investigators. Moreover, a defendant can NEVER be put on the witness stand, let alone questioned, by the government, so don't do off of the witness stand what they cannot compel you to do on it.
“I thought I had to [talk, let them in my house, let them search, etc.]” comes the refrain when we ask witnesses and clients why they talked and helped their captors. No, you don't, ever; nor should you, ever.
You never have to talk to the cops [or other government], and you should not. It never, ever helps - anyone but them. They exist to put cases together and to promote themselves; they do not exist to help you, to be your friend, to understand why you did something, or to give you a break. Wake up, smell the roses, and protect yourself.