Your mistake is quite common, and it happened in the step of converting a text question into mathematical language.
Think about what the expression "the range of $f$ contains $[0,1]$" actually means. It means that $[0,1]$ is a subset of the range of $f$, or in other words, that every $y\in[0,1]$, is an element of the range of $f$.
For example, the function $f(x)=x$ satisfies the condition "the range of $f$ contains $[0,1]$", since the range of $f$ is $\mathbb R$, and $\mathbb R$ contains $[0,1]$.
On the other hand, the function $g(x)=\frac12$ does not satisfy the condition, because the range of $g$ is $\{\frac12\}$.
Another function, $h(x)=\sin^2 x$, also satisfies the condition, but "just barely", since the range of $h$ is $[0,1]$, which contains $[0,1]$ (but any smaller set does not).
Now, think about what the demand $0\leq f(x)\leq 1$ actually means. It means that for every $x$, you have $f(x)\in [0,1]$. In other words, you demand that the range of $f$ is contained in $[0,1].
Let's take a look at the previous examples:
$f(x)=x$ does not satisfy this condition, since $f(x)\leq 1$ is not true for $x=3$.
$g(x)=\frac12$ obviously satisfies this condition.
$h(x)=\sin^2 x$ satisfies this condition, but barely (both $0$ and $1$ are reached by $h$ at some point).
So, the conclusion here is that you were looking at functions that have ranges, contained in $[0,1]$, instead of looking at functions that have ranges that contain $[0,1]$.