From one vertex of an octagon you can draw 5 diagonals.
There are 8 vertices in an octagon, and we are choosing one as our starting vertex. There are then 7 vertices left to draw a line to, but 2 of the vertices are already connected to our main vertex (because they are connected along the side of the octagon). That leaves 5 vertices to draw a diagonal to from our original vertex.