When an object is in motion, such as a falling pencil, it posseses energy, there fore something must absorb it's energy to stop it to a rest. (example- a car in motion stops by the brAke absorbing it's energy). But energy is never destroyed or created, it can only be transferred from one form to another (example- the cars brakes heat up when used because the cars energy is being transferred to heat energy). So, the instant the falling pencil strikes the ground, it stops
falling correct? But the energy the previously falling pencil possess must be transferred to another form of energy the energy can't be
"lost" right? So what happens is some of the energy is converted to heat when it strikes the ground, you may not believe it but there is heat when it hits the ground because of friction. Furthermore, some of the energy is also converted to sound energy. (the pencil makes a sound when it hits the ground and sound is energy) but the heat and the sound energy combined is not enough to transfer all of the energy of the falling pencil. So where does this little extra energy go? You guessed it! Back up! It hits the ground, it goes back up because not all of it is transferred to another form such as sound or heat so it must go back up- or as you said, bounces. Hope this helped you understand.