An idempotent function $\mathbb R \to \mathbb R$
Answer to 1.
A continuous function is such that given any sequence $(x_n)$ such that $x_n\to x$, then $f(x_n)\to f(x)$.
First, note that if $f$ takes two values $f(x_1), f(x_2)$, because of the intermediate value theorem, it must take all the values in between. This means that the image is an interval with possibly infinite endpoints.
To see why the interval is closed, suppose that $y$ is a limit point of the image, i.e. there exists a sequence of values $f(x_n)$ wich converges to $y$. The continuity of $f$ implies $f(f(x_n))\to f(y)$, so that $f(x_n)\to f(y)$ by idempotency. Since the limit is unique, this means that $f(y)=y$, so that $y$ is part of the image.
This proves that the image is a closed interval. I think the infinite endpoints must be allowed, take for instance $f$ to be the identity function: then the image is $\mathbb (- \infty,\infty)$.
Answer to 2.
Your result says that at each point $x$, either $$f'(x) = 0 \text{ or } f'(f(x)) = 1. \label{a}\tag{1}$$ Evaluating this last statement at $y = f(x)$ and applying idempotency, we get that either $f'(y) = 0$ or $f'(y) = 1$ at each point $y$ in the image of $f$.
By part 1, we know that the image $I$ must be a closed interval.
If $I$ contains just one point, then $f$ is a constant. Otherwise, we know that $I$ is a proper interval, and $f | _I$ is either a constant or the identity in virtue of Darboux's theorem following Emanuele Paolini's answer (since no other linear functions are idempotent).
We can readily rule out the case where $f|_I$ is a constant. This would imply $f'(f(x)) = 0$ for all $x$ and so, by $\ref{a}$, $f'(x) = 0$ for all $x$ and $I$ reduces to a point.
If $f|_I$ is the identity, we will argue that $I = \mathbb R$. Suppose the image of $f$ has an end on the right, $b$. Then $b$ is the maximum value of $f$. Taking the limit from the left as $x \to b$ we find that $f(b) = b$, i.e. it takes its maximum value at $x=b$, which implies $f'(b) = 0$ by the extremum value theorem. However $f'(b) = 1$ taking the limit from the left, a contradiction. The argument is analogous for a lower bound $a$. Thus, $I=\mathbb R$ and $f$ is the identity.
A differentiable function whose derivative is either 0 or 1 has constant derivative, in view of Darboux property: if the derivative has value 0 and 1 then it has also all the intermediate values.