A gas exerts pressure on the walls of the container because
molecules of a gas are in random motion
The molecules of gases are free to move randomly in all directions. During their motion, they collide with one another and also with the walls of the container. The constant bombardment of the molecules on the walls of the container exerts a steady force. This force acting per unit area on the walls of the container is called pressure. Thus, gases exert pressure on the walls of the container.