Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!
If you're referring to the top layer, well that's the first shield to contaminants, that's why it should be non-nutritive and sterile, so no contams can find it a suitable to germinate and grow.
If the mycelium is healthy and it gets contaminated bellow the top layer when cased, then a) the layer material is not fully sterilized, b) the casing containers are not fully sterilized, c) contamination has managed to pass through the top layer and find mycelium as a suitable place to germinate.
If you take c) as an answer, then you should work on having a sterile terrarium and take extra precautions on the watering material and surrounding environment because of air exchanges.
Bacteria or other contaminants can "crawl" to the mycelium bellow a top layer, be it driven by a drop of water, or by settling on the top layer surface and then finding its way to the mycelium bellow.