This happens when eggs are overcooked or not cooled quickly after boiling. It’s called a sulfur reaction and occurs due to the reaction between iron in the yolk and sulfur in the egg white.