one reason is that in ancient greece, people emphasized pride (hubris) and honor to their family name. he ends up telling Polyphemus his name because it was in his nature to show off and humiliate Polyphemus. another reason would be to continue the story.
hope this helped!