If you watch police shows on television, often police will forget to read the defendant his rights. Then the lawyers in the show will argue that his “Miranda rights” were violated and he should be let go.
In the real world, defendants rarely benefit from the protections in Miranda. That’s because police usually do read the defendants their rights, and the defendants agree to talk. If you’re read your rights, and you agree to talk anyway then Miranda doesn’t apply.
Or the police question the defendant while the defendant is free, on the street. If the police question the defendant while he’s not in custody, the police don’t have to read him his rights.
Miranda rights come from the case Arizona v. Miranda (1966). Ernesto Arturo Miranda was ultimately convicted of the crime of rape, but only served 5 years.