Each vertex (corner) can have a diagonal to each of the other vertices EXCEPT itself, and it's two neighbours (because those would be sides, not diagonals).
Then multiply by the total number of vertices (which is the same as saying the number of sides).
But that would mean you were counting each diagonal twice - once from each end, so divide by 2
Therefore the number of diagonals = (number of sides) * (number of sides-3) / 2
(I knew I'd explained this one before - here
- which is the same explanation in slightly different words.)