an refers to the nth term of a sequence, and so
a1 refers to the first term in a sequence - this matches with your
a, which you define as the first term in the sequence.
What they've done is they've taken the formula
Sn=2n[a+(a+(n−1)d)] (which is the same as yours, I've just written
2a=a+a and put some brackets). Notice that what is inside the curly brackets is the nth term of an arithmetic sequence and
a is the first term. This thus means that the sum can also be expression as
Sn=2n[a1+an].
That is what they have started with - and they have then realised, they don't have
a31, but they do have a common difference, so they reverted to your formula instead. It's a bit of a roundabout method, but it's important to know that both formulae exist and they're just algebraic manipulations of each other.
Hope that somewhat helps. If you still don't understand, just let me know