If we look the working of the piston then it go first up and then down and the reason of it moving up and down is the burning of the mixture of the present and the air which is present above which expands quickly and its moves the piston in the downward direction and then comes back in the upward direction because its attached with the shaft which moves in the round direction. The working of the piston is that it fills up the most part of the cylinder which is basically a hole.