A precise answer assumes that you have a good understanding of quotient spaces and their relation with equivalence classes.
Assume that each edge of the polygon is assigned a parameterization by the domain $[0,1]$ which goes in the counterclockwise direction around the boundary of the polygon. For instance, if your polygon is literally a Euclidean polygon with straight sides then a side $PQ$ with initial vertex $P$ and terminal vertex $Q$ can be parameterized (using vector operation) as
$$\gamma(t) = P + t \, (Q-P)
$$
Define the "gluing relation" to be the smallest equivalence relation $\sim$ on the polygon satisfying the following:
If two sides of the polygon have parameterizations $\gamma_1,\gamma_2$, and if those two sides are labelled with the same letter and the same sign by the given labeling scheme, then $\gamma_1(t)\sim\gamma_2(t)$.
If two sides of the polygon have parameterizations $\gamma_1,\gamma_2$, and if those two sides are labelled with the same letter and opposite signs by the given labelling scheme, then $\gamma_1(t) \sim \gamma_2(1-t)$.
Then form the quotient space of this equivalence relation.
One can prove that the quotient space is well-defined up to homeomorphism independent of the choices of parameterizations, depending only on the "labelling scheme".