As one moves across a period, from left to right, both the number of protons and electrons of a neutral atom increase. The enhancing number of electrons and protons results in a greater attraction between the electrons and the nucleus. This uplifted attraction pulls the electrons nearer to the nucleus, therefore, reducing the size of the atom.
On the other hand, while moving down a group, there is an increase in the number of energy levels. The enhanced number of energy levels increases the size of the atom in spite of the elevation in the number of protons. In the outermost energy levels, the protons get attracted towards the nucleus, however, the attraction is less due to an increase in the distance from the nucleus.