Please explain the difference between X's Y and Y of X. Example: "The building's roof" and "roof of the building". Is there a "correct" form? When is the former used and when the latter?
X's Y is English's* go-to possessive construction (with or without pronoun), the one used most frequently when comfort allows.
the goalkeeper's job
Here it would be a foreign locution to say "the car of John" (although in some cases it would be normal to say "the job of the goalkeeper" in constructions like "The job of the goalkeeper is to keep the opponent's ball out of the net"; this emphasizes job where the goalkeeper's job would emphasize goalkeeper, but that only works in certain cases; no native speaker is ever likely to say "the car of John" without trying for some curious effect).
Similarly, one would refer to "Alice's schedule" or "Maria's chocolates," not "the schedule of Alice" or, even worse, "the chocolates of Maria"; note that if one read "The Chocolates of Maria" that would be assumed to be something like the name of a store or the title of a book, and even there "Maria's Chocolates" would be much more likely.
I can think of a case where "my X" gets turned around, but it is done so for emphasis. There's a cliché in American business used to tell someone else to back off. "You're not my boss" gets switched into "You're not the boss of me," drawing special attention to the statement. But such cases are unusual, to say the least, and should be reserved for pronouncements that lean toward the rhetorical.
The Y of X is used when X's Y would be awkward or when a loftier tone is indicated or desired:
The Constitution of the United States Here "the United States's Constitution" is infelicitous in a way that "France's Constitution" would not be, but using the Y of X pattern here makes the document sound more important.
the Queen of England This is a formal title. While it's also fine to say "England's queen," normally one would only use this construction when comparing that personage with female monarchs of other countries, and if you capitalize Queen—England's Queen—it's almost a redundancy, at least in Britain, where uppercase Queen means the Queen of England. This applies also to the Duke of Cornwall, the President of the United States, the Under-Assistant Secretary of Sanitation of the Lesser Antilles (should such a position exist), etc.
The Guns of August This book title has a more declamatory feel than would "August's Guns"; it is a lofty, important phrase better suited to the intonation of a stage actor than some bar companion's mumbling*.
a book of poems This one is unlike the others in that it's not really possessive. I include it here in case you might wander down the path of assuming X of Y always has to indicate possession. In this case, the Y's X pattern—"poems' book?"—makes no sense.
Now, getting to one of your own examples, some can go either way without prejudice.
The roof of the building
The building's roof
Here it doesn't really matter which one you use. It depends entirely on how it sounds to you.
The roof of the building was covered with snow.
The building's roof was covered with snow.
I hope I've exhausted this topic, but I'm sure there must be other cases. If I think of more I'll add them.
I was just now involved in practicing Spanish translation on the Duolingo site, and encountered this Spanish sentence:
Mucha de la correspondencia de Ada Lovelace se encuentra archivada en la Biblioteca Bodleian de Oxford y el contenido revela la imagen de una mujer apasionada, ambiciosa pero también imperfecta.
Without even thinking, I let the literal Spanish override my thinking:
Much of the correspondence of Ada Lovelace . . .
Then, an hour later, I got a notification that my translation had been edited to
Much of Ada Lovelace's correspondence . . .
I had to admit that this is better, more "Englishy" than what I had written. Not that my knee-jerk reaction was wrong. It was just a bit clumsier than it needed to be.
* See what I did there?