Let me explain to you the first example. For the second I have to dig through my books a bit because I don’t know the rule by heart…(another tutor might, though )
Normally when using „um zu" we have an adverbial determination. This is a big grammar word to describe a part of the phrase. This part of the phrase describes then either a consequence of the main clause or its purpose.
Let’s have a look at your example:
„Ich habe Zeit," (=main clause that states illustrates a condition, which is that you have time)
„einen Kaffe zu kochen" (=adverbial determination which states the consequence, which is that you make yourself a coffee)
Let me give you another example:
„Wir sprangen ins Wasser, um uns abzukühlen" (We jumped into the water to cool off )
„Wir sprangen ins Wasser," (=main clause = fact)
„um uns abzukühlen" (= adverbial determination = purpose -> you did this in order to cool off)
In these two cases the correct use is „um zu", but especially when dealing with written language, „um" can be omitted without any difference in semantic meaning. This means you can use „um zu" or just „zu" to build your sentence and it is always 100%ly correct.
Let me know if you have any questions concerning this first example, meanwhile I try to come up with an explanation for the second example