It has been speculated that Goering was provided with a cyanide capsule by a sympathetic guard. I say "speculated" because no one knows for sure. But, that's the most logical reason.
The reasons can vary, but there are plenty of ingenious ways to smuggle something small in, and of course the bed sheet rope or something similar can work in a pinch. The prisoners at Nuremburg were only checked up on every 20 minutes or so for this reason (and possible escapees). 20 minutes is enough to pop a capsule or hang yourself.