Why do I keep getting swallowed by black goo?
This annoying black goo keeps sprouting up from the ground, engulfing me, and dumping me in a pit.
Why does it do this and how can I make it not happen again?
You have entered the domain of what I like to call the "Swamp Claws"(Since I have no idea what they are actually called).
As you have already seen, they love to lurk underground, snatch you up when you least expect it, and spit you out in the same, very inconvenient hole over and over. This for me was one of the most annoying areas of the game, but don't lose heart.
Swamp claws like to lurk in flat areas, and don't like slopes. So keep to the board walks and slopes where you can. But remember you can't jump while sliding down a slope.
There isn't much else you can do other than remember very closely where each one is located. There is a special item you can get however. If you look around the swampy area for secret exits and climbing ropes, you can find hidden in a chest containing the golden swamp claw, which grants you the ability of "swamp claw vision", so you can see a twinkling dot wherever a swamp claw is hiding.
EDIT: Here is a (hopefully) simple guide to the Golden Swamp Claw.
Assuming you know your way to the swamp/mud area, travel to the right of the entrance, as per the helpful and overly large arrow:
You should then find a tunnel down-wards, take it (make sure you watch out for those swamp claws).
Coming out of the tunnel, you should see some boardwalks. Follow them to the left of the tunnel exit.
At the end of the platform, you should be able to see some small platforms that lead to a ledge above you. That's where you're headed.
There won't appear to be much on the ledge once you reach, but just on the right wall is a hidden doorway (highlighted in the pic) that you'll need to take.
Head through there and... BAM! SECRET PASSAGE! You'll find a friendly cat-sized rat waiting to guide you to the exit. (Not that you'll find the path that diffucult... and where was this cat-rat earlier?)
There are other secrets here, (I'll let you find them on your own ;) ) but for now follow cat/rat and his pal to the huge, gaping, and very obvious exit and step on through.
Alright, all that's left now is to do some platforming to the left...
...descry yourself the chest, and...
GOLDEN SWAMP CLAW ACHIEVED!!!
You will be able to see the effects of the Golden Swamp Claw immediately. As noted above, you'll see multiple small twinkles wherever a nasty swamp claw is lurking. I've highlighted the effect here:
Here is a "map" of sorts. I've approximated the location of the screen shots and arranged them in relation to each other. Note that I don't really know where the secret passage is located (I hear it's a secret), so I just added that bit to the bottom of the map, with labels to mark entrance and exit locations.
Hope this helps you! :)