Try to think of "the" referring to some specific object or person, and "a" referring to any object or person.
Thus, you would say "Give me the hammer" when you want a particular hammer - perhaps the hammer already being held by the person to whom you are speaking, or when there is only one hammer in the toolbox. If there are several different hammers in the toolbox, and you don't care which one you get, you would say "Give me a hammer".
Similarly, consider these two sentences:
1. I found a stone in my pocket, and I threw the stone into the water.
2. I found a stone my pocket, and I threw a stone into the water.
In the first sentence, it is pretty clear that the stone thrown into the water was the stone that he had taken from his pocket.
In the second sentence, it is not certain that it was the same stone. Having found a stone in his pocket, he may have picked up another stone from the ground, and thrown that one into the water.