Let's have some values. The sides of the square be 4 (a multiple of 2, just in case)
From similar triangles, we get the red line as having a length of 1.
From symmetry, we get the central broken blue line as having a length of 2.
Hence, the side of one triangle in the octagon is 1.
As you see, the octagon is a regular octagon and as such, if you divide it into 8 triangles with a vertex at the centre of the shape, you get each triangle with apex angle 45 degrees.
Do you know the area of such a triangle?
Hence the area of the octagon = area of 8 triangles =
And the area of the square is 4 x 4 = 16.
Ratio of areas =
EDIT: Sorry, wrong assumption here. See post below.