It's called a Ribbon Worm. The stuff coming out is called a proboscis and the worm keeps that inside its body until it forcefully squeezes out the appendage to catch small animal prey. This feeding appendage is held in a sheath or sack above a ribbon worms gut. When prey is detected, muscles rapidly contract and force fluid into the sheath, which turns the proboscis inside-out and forces it through the proboscis pore at the head .