The quick answer is that there's no connection between the gingerbreadman and the muffin man, although both are kind of warnings.
The Muffin Man is a reference to accepting cookies (or muffins) from strangers -- in real life a serial killer of children in particular. (start with: https://en.uncyclopedia.co/wiki/The_Muffin_Man to get the flavour)
The gingerbread man was more akin to Aesop's frog fable, or the one with the scorpion -- sometimes accepting help is the greatest danger...
The thing is, Shrek "borrowed" ideas and concepts from many different sources, especially old folk tales and nursery rhymes.