When a string is bowed, the bow moves across the string and causes the string to vibrate. The bow hair creates friction with the string, which causes the string to move back and forth. The frequency of vibration is determined by the speed of the bow and the string's length, tension, and mass.
When a string is hammered, the hammer strikes the string and causes it to vibrate. The hammer creates a force that displaces the string from its equilibrium position. The frequency of vibration is determined by the hammer's velocity, the string's length, tension, and mass.
In all cases, the vibrations of the string cause the surrounding air to vibrate, which creates sound waves. The sound waves travel through the air and can be heard by our ears.