Is writing recommendation letter job for a faculty required? Do professors who are in a position to write a recommendation letter for me "have to" write a recommendation letter? For example, my PhD advisor, can he suddenly (without any reason) say that he won't write a letter? I mean does it depend on their will?
More specifically, if some professor has promised me a recommendation letter earlier, can he suddenly change his opinion without any reason?
As stated in the other answer, no professor has to write a recommendation letters for a specific student. The most common reason is that it would be a letter the student wouldn't want anyway, ie a bad recommendation. 

On the other hand, it is part of the job of a professor to write recommendation letters for students in general. So if a professor states that he/she categorically refuses to writes recommendation letters for anyone that would be a reason for complaint to their dean or head of department.