Please pay attention to the typesetting used in the forum. so if you quote an input, please wrap it into a “triple quote” section ("```") so that the forum software will not try to interpret special characters in the input as typesetting directions.

Please also, put your question into the body of the post and not the subject line (that should just have a brief summary), so that it will be easier to quote specific statements.

The box enlarges because you ask LAMMPS to do that (you are using shrinkwrap boundaries in Z direction). But how is that incorrect? The system size in Z is effectively infinite anyway.

Actually, I want to have only an indent or a scratch with the atoms on the sample being attached to the sample. In my case, a significant fraction of atoms is escaping the substrate along the + z-direction and hence simulation box is being enlarged. Please do let me know how to solve this issue.

LAMMPS will do what you ask it to do. If the indenter is hitting your your sample too fast or too deep you have to change the fix indent settings. These are all input parameters and your choices, so it is all up to you.