There are a number of possible ways to do this. Let us look at two of them.
First, we could arrest every person we catch crossing the border illegally and jail them rather than deporting them. This would presumably deter others from trying to cross.
Alternatively, we could try to prevent illegal immigrants from wanting to cross the border. In general, illegals enter the country to find jobs. If we strictly enforced laws against hiring illegals, there would be no jobs for them to take. This would, presumably, deter them from trying to cross the border.