The proof makes use of the pigeonhole principle.
First suppose $L(M)$ is infinite. This means that for every $k \geq 0$ there exists a $w \in L(M)$ with $|w| \geq k$. Therefore there must in particular exist a $w$ with $|w| \geq |Q|$. Take the shortest such $w$ and let $w = a_1 a_2 \ldots a_k$. When reading $w$, $M$ will visit $k+1$ states $q_0, q_1, \ldots, q_k$ where $q_0$ is the initial state and $q_k$ is an accepting state. Since $k+1 \geq |Q|$, some state must occur at least twice in this sequence: Now consider the first such repeated pair, $q_i$ and $q_j$. We have that the substring $a_i...a_j$ has length at most $|Q|$. The string $a_1 \ldots a_i \ldots a_j a_i \ldots a_j \ldots a_k$ will be accepted, and its length is at most $2|Q|$.
Next suppose there is a string $w \in L(M)$ where $|Q| \leq |w| \leq 2 |Q|$. Again consider the states that $M$ will visit when reading $w$ and let $w = a_1 a_2 \ldots a_k$. As in the proof of the converse implication above, we notice that when reading $w$, $M$ will visit $k+1$ states $q_0, q_1, \ldots, q_k$ where $q_0$ is the initial state and $q_k$ is an accepting state. Since $k+1 \geq |Q|$, some state must occur at least twice in this sequence. Again, consider the first such repeated pair, $q_i$ and $q_j$. We have that for every $m \geq 0$ that the string $a_1 \ldots (a_i \ldots a_j)^m a_{j+1} \ldots a_k$ will be accepted, and this proves that $L(M)$ is infinite.