"I have a gun" "What for?" [This means - "Why do you need to have a gun, is there a reason for having it?"]
"I have a gun" "For what?" [This means - "What are you going to do with the gun, how are you going to use it?"]
These are both actually used interchangeably. There is no difference in the answer they seek.