A hammer was a tool, usually used to drive nails into wooden objects.
A gavel was an object similar in function to a hammer. It was used by Human, Klingon, and Bajoran judges to demonstrate their power and authority in a formal trial or hearing. (ENT: "Judgment"; Star Trek VI: The Undiscovered Country; DS9: "Dax", et al.)
In 2267, Commander Spock used the example "...if I let go of a hammer on a planet that has a positive gravity, I need not see it fall to know that it has in fact fallen" to explain the effects of gravity. (TOS: "Court Martial")
In 2370, after her encounter with a Bajoran Orb, Major Kira Nerys told Vedek Bareil Antos that all she saw was "lots of hammers, nails and saws, surrounded by lots of Vedeks," when in actual fact her vision was much different. (DS9: "The Circle")