If you shrink the box, the particles have less distance to travel before they hit a wall, so you’ve increased the number of times the particles hit the walls of the box per second, which increases the total force on the wall. Because the box is now smaller, the area of the walls is smaller, so there’s a greater force on a smaller area, meaning the pressure is greater.