When the ball hits the wall, the wall drives the entire earth to move in the opposite direction. The momentum of the system is conserved. The momentum of a single object in the system is not conserved, because if viewed separately, the ball is strongly supported. The force is an external force, and the momentum of the ball is certainly not conserved.
If a system is not subject to external forces or the sum of the external forces is zero, the total momentum of the system remains unchanged. This conclusion is called the law of conservation of momentum. The law of conservation of momentum, the law of conservation of energy and the law of conservation of angular momentum have become the three basic conservation laws in modern physics. The law of conservation of momentum is derived from the translation invariance of space, the law of conservation of energy is derived from the translation invariance of time, and the law of conservation of angular momentum is derived from the rotational symmetry of space.