With hammer-ons you have to put your finger down on the string with some force behind it so when you hit the string it vibrates more. Be careful to hit the string with the tip of your finger else you'll probably hit one of the other strings.
When you master these two skills they're really useful to apply to your playing as it allows you to play faster.