(1) Noun1 + of Noun2
or
(2) Noun2 + Noun1 (the attributive noun form, not the possessive 's form mentioned in OP's title)
For simplicity, I will use the 2 numbers in my descriptions below.
I prefer (2) for its conciseness if Noun2 is not too long. For a long Noun2, the Noun2 + Noun1 phrase becomes unclear; readers will start to wonder where the actual noun is. Using (1) would improve the sentence in such a situation.
Thoughtco Usage Guideline: Multiple Attributive Nouns further explains
this problem caused by noun clusters and gives an example:
FAX TRANSMISSION NETWORK ACCESS COST OPTIMIZATION PROPOSAL
The problem arises when a whole slew of nouns are crammed together. The poor reader's brain has no way to decode this mess until he or she has already gone through it once.
That FAX example to me may not be so bad if the long attributive noun is in the title as readers should still be able to find the actual noun quite easily. However, if the long string is not in the title (as a warning) and appears suddenly, surrounded by more words in the document body, it would affect the readability.
To answer your questions on when we can use (2), and when only the (1) is acceptable, I would say there are no fixed rules against using (2). Thoughtco says
it has always been legal in English to use one noun to modify another noun
and I extend the application to reasonable noun strings.
Normally, I would use this construction if the particular Noun2 + Noun1 phrase is generally accepted and does not affect the rest of the sentence. In the correctly phrased
the leg of the table in my room
Noun2 has a post-modifier, and hence (2)
the table leg in my room
would be less clear than (1).
For the cafe question, my preference is the university cafe.