The reason food goes cold is that it is constantly losing heat via Conduction, Convection, and Radiation. Conversely, the reason drinks go warm is that the environment around them is constantly heating them, up via the same methods of heat transfer.
Vacuum flasks work by preventing all three methods of heat transfer using clever yet elegant countermeasures.
Vacuum flasks consist of two flasks, one inside the other, with a vacuum separating the two, hence its name. By definition, the vacuum has a very low density of particles, which means that it is an extremely poor conductor of heat. Furthermore, because the flasks are only joined at the neck, there is very little heat that is transferred through it via conduction.
Similar to regular bottles, vacuum flasks reduce convection because the lid physically stops the hot air around the food from escaping into the environment. Moreover, when heat eventually leaks from the inner flask via conduction, the near-vacuum between it and the outer flask means that the rate of heat transfer via convection is greatly reduced (because there is no air to move around).
It's not a coincidence that most vacuum flasks are made of metal. Not only does it provide structural support so that it doesn't break from the air pressure versus the vacuum (or by simply dropping it), but it also stops heat loss via radiation. This is because metal is reflective, which means that it will simply reflect the photons emitted by the food, which will then get re-absorbed.