I was reading an analysis textbook, and I came across with a theorem says that a set is compact iff it's closed and totally bounded.
But if we consider the unit interval in the metric space $\mathbb{Q}$, which is a famous example for a closed bounded non-compact set, isn't the set also totally bounded too? Since given any $\epsilon >0$, we can cover $[1,0]$ with intervals of length $2\epsilon$? Doesn't that then make the set compact?
The equivalence between compactness and "closed and totally bounded" is only true in complete metric spaces. Since $\Bbb Q$ is not complete, you need to require more than closure, you need to require completeness.
Namely, a metric space $(X,d)$ is compact if and only if it is complete and totally bounded. You are absolutely right that $\Bbb Q\cap[0,1]$ is totally bounded, by the argument that you present. And you are right that it is closed in $\Bbb Q$.
But while in $\Bbb R$ being closed is enough (because a closed subset of a complete metric space is complete); in $\Bbb Q$ it is not enough to be closed in order to be compact.