Question about Surface of genus g

I understand the construction of a torus from a square by pasting opposite edges of a square and also its CW structure of that.

It's easy to imagine.

But how to understand the construction of a surface of genus 2g from a polygon with 4g sides and its CW structure. Because in the torus case by folding and pasting the square we get the object. This we can imagine.

But in the 2g genus case how to imagine the procedure.

-

I do more graph theory, but we touch on a bit of topology there, so assuming that I understand your question, it's basically the same procedure.

Using a diagram such as this one, you paste the edges marked with the same letters together. You line up the two edges with the same letter in such a way that the arrows are pointing in the same direction. If you think about it for a few minutes, you'll see how this forms the handles for an orientable surface, or the crosscaps for a non-orientable surface.

For example, let's look at diagram 8.5.4 in the link. For those following along at home, this is a surface with two handles, so the flat representation is an octagon, with edge sequence

$$aba^{-1}b^{-1}cdc^{-1}d^{-1}$$

where the negative one means that the edge has direction reversed. So we start by pasting $a$ to $a^{-1}$, remembering to keep the arrows pointing in the same direction, which you can imagine forms a sort of cylinder with $b$ as an edge. Now you can paste $b$ to $b^{-1}$, which is a little harder to visualize but if you stare at it, you'll see that you have formed a handle. Now repeat with the other 4 edges, and you have a surface with 2 handles.

-

The inside of the polygon is the $2$-cell that you're attaching to the $1$-skeleton (a bouquet of $g$ copies of $S^1$) in the natural way.

-