I think you're asking two different but related questions here: one on indices, and one on expectations. I'll answer the question on expectations first, then explain the one on indices.
The two equations are the same, though admittedly this is confusing. This is something that's rarely explained clearly on this topic (at least in econometrics textbooks) so your confusion may well be because it's never been properly explained to you.
It's important to remember the difference between four different things: a random variable, a realisation of that variable, an observation, and a non-random variable. I'll illustrate these differences, using the notation of the first equation.
In some introductory textbooks on linear regression, $a$ and $b$ are taken to be constants, $X$ to be a variable (this is what textbooks mean when they say $X$ is fixed), and $u$ to be a random variable (usually normally distributed with mean zero, and independent of $X$). If then $$Y = a + b X + u,$$ then it follows that $Y$ is a random variable, since anything that is a function of a random variable is also a random variable. In this way, we are treating $Y$ as being random only through the error $u$. We then want to find the parameters of the equation:
$$ E(Y) = a + bX.$$
Note that $X$ has not changed: it is still a variable. This means that $E(Y)$ is a variable, and the equation gives the regression line.
In other textbooks, $X$ is taken to be a random variable. In this case, $Y$ is random both through the randomnesss of $X$ and of $u$. In this case, we want to find the parameters of the equation:
$$ E(Y | X=x) = a + bx.$$
In this case, we needed to de-randomise $X$ in order for $E(Y)$ to not be a random variable. Note that the two equations are mathematically identical: we just had to de-randomise $X$ in the second case.
Regarding the indices, its important to remember that they indicate a particular observation - the ith observation in your n observations - not a realisation of a random variable. Basically, "observation" does not necessarily mean the same thing as "data"/"realisation"/"value", although it can: it depends on the author.
I hope this helps.