Everyone is the hero of their own story. This implies that every person thinks they're doing the right thing.
So if they've been accused of a crime, there must be some misunderstanding. If I explain what happened they'll let me out because I didn't do anything wrong.
It's not the only reason people talk, but it's a big one.
Remember, the line is: " you have the right to remain silent, anything you say, can and will be used against you".