If you've been granted immunity, the fifth doesn't apply because it can't be used to convict you;
Dipshit Prosecutor: The defendant claims he was with you on the night of the 15th. What were you doing on the night of the 15th?
Witness: I plead the 5th.
Jackass Judge: Nonono, you don't have rights because I am a retard! Answer the question or go to jail.
Defense Attorney: WTF? Are you kidding me?
Dipshit Prosecutor: He won't be charged for anything he says because we grant him magical immunity. Promise!
Witness: Okay, well I was busy across town raping children in the basement of that building I shot the President from a few days earlier. I was there for a damned week, just raping a bunch of kids I had stolen earlier to pass time, because I had to wait for the cops to leave.
You can't know what someone will say in their answer before you force them to answer, thus you can't grant them immunity for their answer.
Thus, you, and the dumbass judges who "think" like you, are fucking retarded. The 5th amendment does not only apply when you're being asked certain questions or when you're being prosecuted. It applies at all times. The government can't legally force you to say anything against yourself..