A six-sided die is rolled 5 times. The roller wins if the last roll is the same as one of the previous rolls.

Write down the results of the five rolls and then read them backwards. You win if the "first" result is ever repeated, and you lose if it's not. The probability of losing is $(5/6)^4$ -- i.e., a given roll does not repeat the "first" result with probability $5/6$, and there are $4$ "subsequent" rolls -- so the probability of winning is

$$1-\left(5\over6\right)^4={1296-625\over1296}={671\over1296}$$


[This is essentially the same as Dominik's answer, but has less notation.]

Let the die have $n$ sides. Let $m$ be the number of rolls before the last roll. In your question $m=4$ and $n=6$. \begin{align} P(\text{win}) &= \sum_{i=1}^n P(\text{win, and last roll is $i$})\\ &= \sum_{i=1}^n P(\text{last roll is $i$, and one of the first $m$ rolls is $i$})\\ &= \sum_{i=1}^n P(\text{last roll is $i$}) \cdot P(\text{one of the first $m$ rolls is $i$})\\ &= \sum_{i=1}^n P(\text{last roll is $i$}) \cdot (1-P(\text{none of the first $m$ rolls is $i$}))\\ &= \sum_{i=1}^n \frac{1}{n} \cdot \left(1-\left(1 - \frac{1}{n}\right)^m\right)\\ &= 1-\left(1 - \frac{1}{n}\right)^m. \end{align}


Essentially, this question is the same as here. I will shamelessly adapt Byron's answer from there.

Assume we have a die with $n$ sides that we roll $m$ times before our final roll. Let $A_i$ be $1$ if we have rolled $i$ at some point and $0$ else. Also, denote by $X$ the last throw.

Now we will win if and only if the random variable $$Y = \sum \limits_{i = 1}^n A_i I\{X = i\}$$

has a value of one. Note that $Y$ only assumes values $0$ and $1$, so we have $E[Y] = P(Y = 1)$. Knowing that $X$ and $A_i$ are independent, it remains to calculate $$E[A_i] = P(A_i = 1) = 1 - P(A_i = 0).$$ But this is easy, since $P(A_i = 0) = (1 - \tfrac{1}{n})^m$. With this we can calculate the winning probability as $$E[Y] = \sum \limits_{i = 1}^n E[A_i] P(X = i) = (1 - (1 - \tfrac{1}{n})^m) \sum \limits_{i = 1}^n P(X = i) = 1 - (1 - \tfrac{1}{n})^m.$$

Side note: We can actually see in this calculations that $X$ doesn't even need to be a fair die, as long as it only assumes values from $1$ to $n$.