I have come across a problem in topology as described in the title. Here is my intuitive construction with analogy to the fundamental group of closed surfaces. Let $G=(a_1,a_2,\dots,a_n \mid r_1,r_2,\dots,r_m)$ be a finitely presented group, then let $l^i$ be the length of each reduced word $r^i$, I define a polygon with $l^1+l^2+\dots+ l^m$ sides, and separately identify each $l^i$ sides as the reduced word $r^i$ suggests. Say, if $r^i = a_1 a_2 a_1 a_2$, then identify the consecutive $l^i$ sides by $a_1 a_2 a_1 a_2$. Then I guess that the identification space we construct is the required topological space, whose fundamental group is $G$. However, this is only an intuitive way, and I don't know whether it is right.
Moreover, can anyone explain to me the details of amalgamation when applying the Van Kampen theorem to closed surfaces? I don't understand why the amalgamation of two groups is the pushout of free products. Your help would be sincerely appreciated, and sorry for my bad typing.
Your construction is close but not quite right. For example, suppose we start with the silly presentation $\langle x:x^2, x^2\rangle$. Then the fundamental group of your space if $\mathbb Z/4\mathbb Z$ instead of $\mathbb Z/2\mathbb Z$.
The standard construction adds one polygon per relation. Your start with a wedge of circles, one per generator, and then glue a polygon per relation. The resulting thing is sometimes called the presentation complex; googling that should find you more detailed descriptions.