In the fourth edition of "Introduction to Real Analysis" by Bartle and Sherbert, theorem 6.2.3 (Rolle's theorem) states,
Suppose that f is continuous on a closed interval $I := [a, b]$, that the derivative of $f$ exists at every point of the open interval $(a, b)$, and that $f(a) = f(b) = 0$. Then there exists at least one point $c$ in $(a, b)$ such that the derivative of $f$ is zero at $c$.
Now, why are we taking $f(a)=0=f(b)$? Is $f(a)=f(b)$ not sufficient?
You are right, taking $f(a) = f(b)$ is sufficient.
But, one can prove the theorem in this general scenario using the theorem for the case $f(a) = 0 = f(b)$, as follows:
Assume Rolle's theorem as stated in the question details is true. Let $f$ be a function satisfying the same hypotheses, except that $f(a) = f(b) = k$, where $k$ is not necessarily equal to zero. Then, the function $g(x) = f(x) - k$ satisfies the hypotheses of Rolle's theorem, and so there is a point $c$ such that $g'(c) = 0$. But $g'(c) = f'(c)$, so we are done.
So, it doesn't really matter which one we use, as both versions are seen to be equivalent to each other.