Assume someone wants to attack an encryption scheme with the following characteristics for a given plaintext P and ciphertext C:
$$
C = \mathit{ENC}_{k_2}(\mathit{ENC}_{k_1}(P))
$$
$$
P = \mathit{DEC}_{k_1}(\mathit{DEC}_{k_2}(C))
$$
where $\mathit{ENC}$ is the encryption function, $\mathit{DEC}$ the decryption function defined as $\mathit{ENC}^{−1}$ (inverse mapping) and $k_1$ and $k_2$ are two keys.
The naive approach at brute-forcing this encryption scheme is to decrypt the ciphertext with every possible $k_2$, and decrypt each of the intermediate outputs with every possible $k_1$, for a total of $2^{k_1} \times 2^{k_2}$ (or $2^{k_1+k_2}$) operations.
The meet-in-the-middle attack uses a more efficient approach. By decrypting C with $k_2$, one obtains the following equivalence:
$$
C = \mathit{ENC}_{k_2}(\mathit{ENC}_{k_1}(P))
$$
$$
\iff \mathit{DEC}_{k_2}(C) = \mathit{DEC}_{k_2}(\mathit{ENC}_{k_2}[\mathit{ENC}_{k_1}(P)])
$$
$$
\iff \mathit{DEC}_{k_2}(C) = \mathit{ENC}_{k_1}(P)
$$
The attacker can compute $\mathit{ENC}_{k_1}(P)$ for all values of $k_1$ and $\mathit{DEC}_{k_2}(C)$ for all possible values of $k_2$, for a total of $2^{k_1} + 2^{k_2}$ (or $2^{k_1+1}$, if $k_1$ and $k_2$ are the same size) operations. If the result from any of the $\mathit{ENC}_{k_1}(P)$ operations matches a result from the $\mathit{DEC}_{k_2}(C)$ operations, the pair of $k_1$ and $k_2$ is possibly the correct key. This potentially-correct key is called a candidate key.