Everybody's familiar with Miranda warnings, but legally, they’re only necessary under certain circumstances.
A way to remember that is Miranda equals custody plus interrogation.
A court determines whether or not you were in custody for the purposes of Miranda by asking whether or not your freedom was restrained in a significant way. There's not a bright-line rule here, and this is a case-by-case analysis.
It ultimately comes down to whether a reasonable person would have felt free to leave or not.
Now, being in custody alone is not enough to trigger Miranda.
For example, let's say you get picked up on a murder warrant. The officer picks you up, puts you in the back of the car, takes you to the police station. On the way to the police station, on your own, you say, "Yeah, I was there, but the guy was alive when I left."
That does not trigger Miranda, because the statement you made was not triggered by the police asking you anything.
In order for Miranda to apply, you have to be in custody, and you have to be subject to interrogation.
In depth reading about Miranda Rights on this Wikipedia article.
Videos suggested for you to watch next