It's a different type of chocolate to usual. They heat and cool the chocolate til it takes on a crystalline structure - and it is harder to melt. Also, the dough of the cookie (or similar) holds the chocolate so it can't really run anywhere. (Most of what I've just written came from the book 'Can Cows Walk Downstairs?', unfortunately not from my own knowledge...)