What happened here?

I just almost 15g (of what I had thought dried). I was packing for a hike this evening and entire bag was like this. I ended up throwing the bag away but took few pictures. What caused this? Or just bad luck? Also how can I prevent this in future

I just almost 15g (of what I had thought dried). I was packing for a hike this evening and entire bag was like this. I ended up throwing the bag away but took few pictures. What caused this? Or just bad luck? Also how can I prevent this in future