How do engines/computers work?
You're asking a pretty complex question, but it's good to go back to basics. There are a couple of concepts to consider:
Evaluation
If a (real) player is shown a position and asked "who is winning this game?", how do they go about deciding? Most likely, they will check a few basic things, such as: material differences, the degree to which pieces have been developed or are positioned "well", doubled / isolated / connected / passed pawns, (controlled) open files, how far up the board the pawns are.
Now, if you had to, you could come up with a systematic way to calculate a position score based on the above. You could decide, for example, that a pawn is worth 1 point, and that a passed pawn is worth 0.3 points more. Isolated or doubled pawns might be worth a bit less, etc. If you add up everything, you get an estimate value for the immediate position at hand.
This is known as evaluation, and basically all chess programs have a way to evaluate positions (ignoring novelty AI chess engines which are typically very weak).
But what about subtle, deep positional moves?
Well, we've only barely scratched the surface of position evaluation. The actual implementation of an evaluation function could be simplistic, to allow for more positions to be evaluated per second (albeit in a rough fashion), or more complex, leading to less positions evaluated, but with a higher degree of confidence. It's not unusual for the evaluation function to take into account hundreds or even thousands of separate pieces of information.
Search
I've specifically left out something from the above, which most real players will immediately think about - is there any way to immediately win the game for either side? Any mates or "hanging" pieces visible? Although it's easy to trivialise this, it's anything but trivial.
What does it mean for a player to have full confidence in a combination? In the end, it boils down to having calculated all options. Real players typically won't do this (except for trivial or very forced mates), most of the time we will only consider a handful of options, and rule out others which seem to be "non-constructive" or obviously leading to a loss. We often make mistakes during this calculation, e.g. we may realise that a change in move orders makes threats evaporate, etc. The point is that to be completely sure of a combination, you actually need to calculate all the way to its conclusion, assuming each player will only make the best possible move available to them (this is referred to as "min/max").
Now, given that chess has a much larger search space (this is what "all possible moves in the future" is referred to) than what is feasible for a computer to calculate, compromises need to be made. Just like humans, computers can decide to disregard entire lines of thought based on certain criteria. This is known as heuristics. It's worthwhile noting that while you can only be really sure of a combination if you brute force it, a complex evaluation function can often detect the presence of threats (e.g. we could count forks, skewer opportunities, etc, to guide a search in that direction).
In the end, although computers are extremely fast, it's the heuristics which allow them to calculate so deep. That said, you may be surprised how deep modern engines calculate fully, typically it's beyond 3 moves, even in quick games.
Conclusion / combining it all
So, to summarise - evaluation functions have a lot of intelligence built into them (i.e. they take into consideration more things than your average human player), heuristics allow the computer to cull lines of thought it decides probably aren't going to end well, and computers are extremely, extremely fast. Add them up, and they're pretty difficult to beat.