Sometimes a character is really based on research that you do. Other times it's just based on your imagination or perhaps your conversation with the director. Or sometimes all of the above. It depends on the movie and character.
If you play it straight it's funny - the best comedy is always played straight down the middle. The adjustment is understanding from the screenplay that a moment is hilarious.