According to Sir Isaac Newtons third law of motion, "For every action force, there is an equal reaction force in the opposite direction." What this means is when you exert a force upon the wall, as the ball does when it strikes it, the wall exerts an equal force back upon the ball, causing the ball to bounce back in the opposite direction. It also depends on other factors, such as the composition of the ball, whether the ball is inflated or flat, and the texture of the wall. The amount of force is determined by the person throwing the ball. A large force will result in the ball striking the wall and rebounding almost in a straight-line fashion back to the person. A smaller force will result in the ball striking the wall with less impact, bouncing in a downward fashion on the return trip to the person.