Ella's answer is excellent when it comes down to how things work practically, but I think a theoretical overview would be appropriate as well. This one is based off the idea to model block ciphers as pseudo-random permutations (PRPs).
Let's first focus on the primitives, ie on block ciphers.
Imagine the space of all functions from $\{0,1\}^n$ to $\{0,1\}^n$. There are $(2^n)!$ such functions. Now if we pick $n=128$ (the standard modern block size), there are $(2^{128})!\approx2^{2^{135}}$ such functions. That is an insane number of functions. Now what any modern cipher does is to pick $2^k$ of these functions, with $k\in\{128,192,256\}$ being common.
So you have $2^k$ possible functions. Most of which have never been used by humanity because the corresponding key didn't get picked. All you have is a few in- and outputs of the function you look for and you want to identify the function (essentially "find the key") or predict some other (particular?) in- and output pair. Technically you could do that by brute-forcing the key, but this is physically out of reach. Theoretically however this is even harder. As an illustration, imagine a set of 32 numbers. Now mentally draw arrows from 8 elements to 8 other elements. Now try to limit the possibilities for the connections among the last sixteen elements. You can't. Now scale this up by a factor of $2^{123}$ to get a taste of how this is for real block ciphers.
So this is how this works for block ciphers. Now to the encryption of real data. In that case we use less sophisticated constructions but involve randomness / state as well. If we were to re-use our previous picture, you'd pick a new function after each evaluation of the function. So doing evaluations allows you to learn just about nothing about the function.