In the first sentence, it is implied that the walking is now over. The walk was two hours, and now everyone is hungry.
In the first sentence, it is implied that the walking is still happening. We walked for two hours, we're hungry, but we still have to walk more.
Both sentences could be interpreted to mean the same thing, too, so it can depend on the context.
The sentences in their current form are not entirely natural, more common would be:
"After a two hours walk, everyone felt hungry"
"After two hours of walking, everyone felt hungry"