A substance A can be a net promoter of both a compound B and a compound C, even if the compound B suppresses C, provided that the direct promotion of A on C is greater than the direct suppression of B on C per the changed in B.
In other words, when I ignite a pile of wood(A), the wood releases (among other things) both water(B) and smoke(C). Now, independently high amounts of water will tend to put out smoke, but in these quantities much more smoke is released than the water required to put it out.
I don't have a source on how much endorphins sugar releases but I would imagine it's an analogous case. In fact, things like this are really common in the human body because if the half lives of action are different, they can help return the body to homeostasis. In this case, I hypothesize that the endorphin effect on insulin could serve to reduce insulin to more normal levels in the blood-stream after the initial spike due to sugar intake.
Also, more anecdotally, how many people do you know who get hangry from low blood sugar? How many people eat when they are sad to feel better?
A medical condition means I can get hypoglycemic, and when I do I can become completely irrational and very aggressive. Also, a drop in blood sugar can signal hunger.