In the books there is a bit more wiggle room : (Farewell to Lorien; last few pages)
'Cram', he [Gimli] said under his breath, as he broke off a crisp
corner and nibbled at it. His expression quickly changed, and he ate
all the rest of the cake with relish. 'No more, no more!' cried the
elves laughing. You have eaten enough already for a long day's march.'
So in the original a whole cake is described as being enough for a day. Also it is described as being crisp so we can guess that it's pretty thoroughly dehydrated.
Shortbread has around 500 kcal per 100g (and also fits the description reasonably well) . Even so 400g of shortbread is a lot to eat in one go but certainly not impossible.
The elves go on to say :
One will keep a traveller on his feet for a day of long labour, even
if he be one of the tall men of Minas Tirith'.
This isn't quite the same thing as saying that it meets your long term nutritional requirements for 24 hours. So it's not beyond the realm of possibility that it also contains some sort of stimulant etc which helps you draw on your existing reserves immediately without necessarily replacing them. This would also explain why they encourage them to go easy on it and only use it in emergencies.
It is also noted later on when Sam and Frodo are travelling into Mordor that they notice that it seems more sustaining and moral boosting when not mixed with other foods which might back this up.
As an aside the complete inedibility of 'dwarf bread' is a recurring in-joke in the Discworld series. First appearing as a footnote in Witches Abroad and greatly expanded upon in The Fifth Elephant and Thud.
EDIT : there is a good point in the comments relating to what 'a long days labour' or 'a days march' might actually mean in terms of calories.
First is the phrasing. Does 'a day' mean 24 hours consecutively or is it 'during the day' assuming extra meals at the beginning and end of the march/work period.
I would suggest that the phrase 'keep a traveller on his feet' might imply that it is the absolute bare minimum to keep going. Survival manuals often quote 1000 calories per day as a minimum to keep active and functional (for short/moderate periods) so it's not entirely unreasonable to see 2000 calories as just about adequate for a week or so of reasonable activity.
For a real world comparison the British Army 24 hour ration packs contain around 4000 calories and weigh about 1.5kg. They are intended to provide the nutritional needs of a soldier over a period of a few weeks and so 4000 Kcal per day is probably a reasonable figure for medium terms needs for fit people doing a reasonable amount of labour. Although equally you wouldn't necessarily expect an infantry soldier to be burning through calories at the maximum possible rate for a human in this sort of period.
Having said that for something which is very clearly 'emergency rations' you could certainly keep going on a lot less that this for a few days albeit with some weight loss. If fat has around 900 kcal per 100g then even a shortfall of 2000 kcal per day is only equivalent to a couple of hundred grams of body fat per day.
The film
In the film version it's Merry and Pippin who scoff lots of Lembas but as the lore of the books establish that Hobbits have very healthy appetites but also are very hardy when push comes to shove this seems like a reasonable stretching of the point both for stylistic comic relief and to make the point that Lembas is very compact calories and perhaps a bit magical.