Consider two squares ABCD and MNOP. The squares are tilted 45° to one another and they share the same centre. They intersect at the points E, F, G, H, I, J, K, L to form a regular octagon. Note that the vertices of neither square are part of the octagon.
(The angle 45° follows from the fact that each exterior angle (supplement of interior angle) of an octagon measures 360/8=45°. The sides of two squares need to form this angle, hence their mutual tilt. The symmetry of a regular octagon implies a symmetrical arrangement of the intersecting squares, hence their common centre.)
Consider the side AB of the square ABCD. Square MNOP intersects this side at K and L. The symmetry of the figure makes the intersections of the other three sides similar, so what applies to AB applies to the other sides, too. Let the length of the side of the octagon be x. The vertex P of square MNOP forms the right isosceles triangle KLP and KL=x because KL is part of the octagon EFGHIJKL.
EL=JK=KL, being other sides of the octagon. KL is the hypotenuse of KLP so by Pythagoras the congruent sides LP=KP=x/√2. Because of symmetry, the length of the sides on all the "protruding" right isosceles triangles around the figure are congruent, making them x/√2 in length.
AK+KL+LB=AB=1 (unit square), so x/√2+x+x/√2=1, from which x=1/(√2+1)=√2-1.
So the length of the side of the octagon=√2-1.
Picture courtesy of GeoGebra Graphing Calculator
The octagon has sides shown in green. Square ABCD is in red except where it forms a side of the octagon. Similarly for blue square MNOP.