Gyroid structure with millipede

Here’s a cleaner way to model a gyroid than using an isosurface

As for thickening extending it beyond the unit cube - that’s to be expected since the surface is not perpendicular to the cube faces.
If you want a repeating unit with thickness and meeting the faces of a cube you’ll need to take a larger patch and thicken that, then cut out a unit cube from the middle of it.