Your question [This is better English]:-
I heard those expressions on TV and I don`t know the difference between THEM. DO THEY Mean the same THING? ARE They used IN different situations?
My answer:-
"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?"]
Suggestion:
The next time you hear something on TV try to remember the whole sentence. It is easier for to explain in context.
Good luck
Stephen