Remainder Theorem: $f(x) = x^3+1$ divided by $\operatorname {d}(x)= x$ Take for example $\operatorname {f}(x) = x^3+1$ divided by $\operatorname {d}(x)= x-1$ $$\frac {x^3+1}{x-1}$$
The Remainder Theorem tells us that the remainder will be $$\operatorname {f}(zero-of-\operatorname {d}(x))$$
In this case the remainder should be $$\operatorname {f}(1) = 1^3+1 = 2$$
so the remainder should be 2 for any value of $x$  
But for $x=3$
$$f(3) = 3^3+1$$
when this is divided by $x-1$ which is $3-1$ which equals to $2$, $$\frac {3^3+1}{3-1}$$ $$= \frac {27+1}{2}$$ $$= \frac {28}{2}$$ $$= 14, remainder = 0 ≠ 2$$
Please explain me why this happened
There is a distinction between the statements :

The division of the polynomial $f(x)$ by the polynomial $x-a$, yields the remainder as the constant polynomial $f(a)$.

and

For each $y$, if we divide the number $f(y)$ by the number $y-a$, the remainder is always $f(a)$.

The difference is simple : one refers to polynomial division, the other to integer division. You seem to think that these statements are both implied by one another. The second, is in fact NOT TRUE.

Why? Well, note that $f(y) - f(a)$ is always a multiple of $y-a$, so what is true is this :

For each $y$, the numbers $f(y)$ and $f(a)$ leave the same remainder when divided by $y-a$.

Now, what if $f(a) \geq y-a$? Then it cannot be a possible remainder when something is divided by $y-a$.
That's what is happening in your example : you have $f(1) = 2$, and $y=3$ so $y-a = 2$ as well. So if you divide $f(3)$ by $2$, you get $0$ as the remainder, which is the same as when you divide $f(1)$ by $2$. But $f(1)$ itself can't be the remainder because the remainder upon division by $2$ can only be $1$ or $0$, which $f(1)$ is not.

Basically, if you want to find the remainder when $f(y)$ is divided by $y-a$, the answer is NOT $f(a)$ , but rather the remainder when $f(a)$ is divided by $y-a$. That number in your case is $2 \pmod 2 = 0$.
$$\frac{x^3+1}{x-1}=x^2+x+1+\frac{2}{x-1}$$
Here $f(x)=x^3+1$, so the remainder when $f(x)$ is divided by the linear factor $x-1$ is a constant 2 as seen above and which is nothing but $f(1)=2$.
If the divisor is quadratic, the remainder is linear function of $x$ or a constant.