From the Super Mario Wiki
Jelly is a substance that makes its first appearance in Yoshi's Story, specifically in stage 2-3, Jelly Pipe. Here, it can be "dug" into by the Baby Yoshi using a forceful move such as the Ground Pound. Sometimes fruit is trapped in the jelly, also. The jelly in this game comes in blue, magenta, and cyan. Sometimes Jelly Ghosts hide in the jelly.
Jelly also appears in the World 7 Ghost House in New Super Mario Bros. Here, it can be dug into with a Ground Pound once again in one room. In another room, it comes in "waves" towards Mario in a room filled with Splunkins. The jelly in this game only comes in green.