Medieval stonemasons used this method to construct exact octagons in a given square window.
Open your compasses to a radius of half the diagonal of the square and construct an arc with centre one vertex of the square - mark the 2 points where the arc crosses the sides.
Do that for all 4 vertices of the square giving 8 points which are the vertices of an octagon. Is the octagon an exact regular octagon? You may wish to explore using the GeoGebra applet below.
Move the slider to rotate the yellow square. Does this help you to prove that the octagon is regular?