Creating a secure key Imagine that your lecturer and the undergraduate office have conducted a key exchange protocol after which both of them hold the string $X$. Yet, it is possible that a curious student sitting next to the lecturer in the bus may have gained some information $E$ about $X$. (Un)fortunately, the student eavesdropper Eve has gained only $1000$ bits of information $E$ about $X$ from the quick glance. If $X$ contains 1 million bits and was chosen randomly beforehand, describe how the lecturer and the undergraduate office can produce a fully secure key $K$ from $X$ to encrypt the final exam for electronic transmission, such that student eavesdropper Eve knows essentially nothing about the key $K$.
I think that it's more proper  for your title to be named "Why hashing the shared value to get session key?" Next I'll answer your question in my understanding.

The basic problem is to establish a shared key between Lecturer  and undergraduate office securely. In the original Diffie-Hellman key-exchange protocol, Alice and Bob use the $g^{ab}$ as their session key. This basic DH protocol is based on CDH assumption, but CDH assumption alone can not ensure that we can use all the bits of $g^{ab}$ securely, it can only make sure that we can obtain  a hard core bit which is unpredictable. So the straight idea is to run the protocol $k-times$ to get secure $k$ bits. But it's undesirable and inefficient. So, in order to make the weak bits of $g^{ab}$ as strong as others, usually we hash the shared value to get the final session key. 

But another problem you need to consider is the key-exchange protocol's security, so  that you can establish a session key between  lecturer and undergraduate office. I think key-exchange protocol's security is more important. And it's vulnerable to kinds of attacks.As your question is not about it, so I just answer you question in my view.