How generator becomes under excited/ over excited?
Question is, what determines these under excitation and over excitation?

The amount that the field coils are excited compared to how much they would be excited for a power factor of unity.

What makes E(terminal voltage) constant irrespective of rotor excitation?

For an introductory class in electric machines, the terminal voltage is presumed to be supplied by the grid.  What makes it constant regardless of rotor excitation is the prof who wrote the book!

Should there be some influence of rotor excitation on E?

Yes, but that gets into how the grid responds to changes in the output of the generator.  That gets into a whole bunch of really complicated stuff*, which is why you can still get a PhD in electric power generation.

What happens in case of a Diesel Genset, since there is no concept of constant terminal voltage E?

Well, there is, sort of.  A genset that's driving a synchronous generator** regulates the field coils so that the generator produces the correct voltage.  A direct side effect of this is that the generator will be over- or under-excited as much as it needs to be to match the power factor of the load while delivering the correct voltage.
* Made more complicated by wind and solar energy, and more complicated yet by the rules the utilities have to follow.
** In other words, not just driving a permanent magnet generator that drives an inverter.