In which way does what you do right after class affect knowledge retention? For example going for a walk in the woods right after the class sounds like a much better idea than to binge watch 5 Rick &amp; Morty episodes... but why?

In which way do your right-after-class activities affect your brain's ability to retain what you've just learned?
The reason you instinctively feel that a walk in the woods is better than TV may be partially related to the schemas you've developed around both activities. You get the feeling that talking a walk is a more "intellectual" activity than TV because that's you expectation based on what you've heard, and your experiences of TV being a lazy activity for pleasure, not because TV inherently "rots your brain".

That said, the other half of things is probably the answer you're looking for. Right after class, your memories of the lecture are still malleable and not yet incorporated into long-term memory. The Wikipedia article on this is a good place to start: 

https://en.wikipedia.org/wiki/Memory_consolidation