While every comedian's joke writing process is different, comedians usually write jokes about life observations or things they feel passionately about. After they have the idea for a joke, they revise it multiple times to determine the best way to write and deliver it.
Comedians are able to write funny jokes because they write frequently to hone their craft and develop their own method. They often don't start out trying to write jokes, they simply write about their current emotions and later develop this into jokes. Since the creative and analytical processes use different parts of the brain, comedians typically separate these processes. That way, they can write a large amount of material and analyze it later.