Bacteria contamination inside a thermos bottle Let's say that I have a pot of boiling stew.
I then pour this, still boiling, inside a thermos bottle, and close the lid right away.

Everything inside the bottle should be sterile at this point, due to the high temperature which will be maintained for over an hour, correct?

Let's say then that I let this sit for maybe 24h.
In this time frame, the temperature of the stew will fall in the danger zone between 60°C and 5°C, and stay there for hours and hours.
Usually, that would mean that the meat in the stew is no longer fit for consumption.

However, given that the content of the bottle was earlier sterile, would it still be safe?
Can bacteria contaminate the content trough the lid?
The assumption that it was sterile is wrong. Standard cooking leads to a reduction of bacteria to about log6, so 1 in 100 000 survives. Afterwards, these bacteria multiply exponentially in your soup, potentially achieving levels at which people can get sick. 

Your logic will apply to canning. But it is known that the "fill the cooked food into an airtight closing container" is an unsafe canning method even for high acid foods, and a thermos bottle is not guaranteed to be closed airtight. If you want to can soup, you have to follow safe canning procedures, which include a restriction of the ingredients you can use, a restriction in the liquid/solid ratio, the prescription of proper containers, and a sufficiently long sterilization step in a pressure canner.