Although the solution below does indeed identify the two-hole torus with an octagon, it does not answer OP's question which was the two-hole torus can be represented by the octagon with opposite sides identified. I do not explain how to identify the opposites sides of an octagon, but rather how to glue two representations of a torus to get a two-hole torus.
Basically, what you want to do is to glue two tori.
Both tori can be identified with the following representation:
Now to glue them together, you want to cut a small piece of each torus, and glue them in a certain way on the area you cut. We are going to cut a small triangle at points $p$ and $q$ as following way:
Note that $p$ and $q$ are note at the same place in both tori!
Now we glue them together, $p$ goes on $p$ and $q$ goes on $q$ which gives:
Redrawing it as an octagon, it gives: