We use the Seifert Van-Kampen Theorem to calculate the fundamental group of a connected graph. This is Hatcher Problem 1.2.5:
It is a fact in graph theory that any connected graph $X$ contains a maximal tree $M$, namely a contractible graph that contains all the vertices of $X$. Now if the maximal tree $M = X$, then we are done because for any $x_0 \in M$, $\pi_1(M,x_0) = \pi_1(X,x_0) = 0$ that is trivially free. Now suppose $M \neq X$. Then there is an edge $e_i$ of $X$ not in $M$. Observe that for each edge $e_i$ we get a loop going in $M \cup e_i$ about some point $x_0 \in M$. Now fix out basepoint $x_0$ to be in $M$ and suppose that the edges not in $M$ are $e_1,\ldots,e_n$. Then it is clear that
$$X = \bigcup_{i=1}^n \left(M \cup e_i\right).$$
The intersection of any two $M \cup e_i$ and $M \cup e_j$ contains at least $M$ and is path connected, so is the triple intersection of any 3 of these guys by the assumption that $X$ is a connected graph. So for any $x_0 \in M$, the Seifert-Van Kampen Theorem now tells us that
$$\pi_1(X,x_0) \cong \pi_1(M \cup e_1,x_0) \ast \ldots \ast \pi_1(M \cup e_n,x_0)/N$$
where $N$ is the subgroup generated by words of the form $l_{ij}(w)l_{ji}(w)^{-1}$, where $l_{ij}$ is the inclusion map from $\pi_1((M\cup e_i) \cap (M \cup e_j),x_0) = \pi_1(M \cup (e_i \cap e_j),x_0)$. Now observe that if $i \neq j$ then $M \cup (e_i \cap e_j) = M$ and since $\pi_1(M,x_0) = 0$ we conclude that any loop $w \in \pi_1(M \cup (e_i \cap e_j),x_0)$ in here is trivial. If $i = j$, $l_{ij}$ is just the identity so that our generators for $N$ are just
$$l_{ij}(w)l_{ji}(w)^{-1} = ww^{-1} = 1$$
completing our claim that $N$ was trivial. Now for each $i$, we have that $\pi_1(M\cup e_i,x_0)$ is generated by a loop that starts at $x_0$ and goes around the bounded complementary region formed by $M$ and $e_i$ and back to $x_0$ through the maximal tree. Such a path back to $M$ does not go through any other edge $e_j$ for $j$ different from $i$. It follows that $\pi_1(X,x_0)$ is a free group with basis elements consisting of loops about $x_0 \in M$ as described in the line before.
Best Answer
I recall enjoying the van Kampen exercises in grad school, so I will give this one a try. The topologists can hopefully add more helpful answers.
As the first example consider the sphere with a single handle, i.e. the torus. You hopefully already know the answer, so let's see how van Kampen does it. We are to split the torus into two parts, $U$ and $V$ with a path-connected intersection, such that we know the fundamental group of $U,V$ and $U\cap V$. Let $V$ be just a small open disk on the surface of the torus. Let $K$ be an even smaller closed disk inside $V$, and let $U$ be the complement of $K$ on the entire torus, so $U\cap V = V\setminus K$ is an open annulus around the perimeter of $V$.
$V$ is contractible and has a trivial fundamental group.
$U\cap V$ contracts to a circle, and has the infinite cyclic group as the fundamental group. A generator of this group is the loop $g$ going once around the circle.
$U$ is essentially the torus with a hole in it made by the removal of the patch $K$. By making that hole bigger and bigger, we eventually see that $U$ contracts to a figure eight 8. If we look at the torus as a bicycle tube, then $U$ is the tube with the valve and its surroundings removed, and it contracts to the union of a big circle $x$ (the points that would touch the ground, if you rotate the wheel 360 degrees) and one small circle $y$ around the tube. These two circles intersect at a single point. So the fundamental group of $U$ is the free group on two generators $x$ and $y$.
What does van Kampen tell us about the fundamental group of the union $U\cup V$? Basically we get the free product of the fundamental groups of $U$ and $V$, but we need to do a bunch of identifications by introducing relations that equate the images (under the induced by the inclusion map) of the elements of $\pi_1(U\cap V)$ on either side.
Here $\pi_1(U\cap V)=\langle g\rangle$, so we only need to check, what kind of a relation we get by equating the image of $g$ in $\pi_1(U)$ and $\pi_1(V)$. In $\pi_1(V)$ the image of $g$ is, of course, trivial, because the loop trivially contracts to a point, once we allow it to pass into $K$. The fun part is to observe that when we "expand the hole $K$ to the complement of the figure 8", the loop $g$ becomes the commutator $xyx^{-1}y^{-1}$ (alter the order of the factors depending on the choices of the orientations that you made).
You may need to draw a picture to see this happening. As a substitute I would suggest that if we form the torus by glueing together the opposite sides of a rectangle in the usual way, then $K$ is a hole in the middle, $g$ is a loop around it, the figure 8 is the border of the rectangle with the obvious identifications, and "expanding the hole" results in pressing the loop to go once around the perimeter of the square.
Anyway, van Kampen tells us now to identify $xyx^{-1}y^{-1}$ with the trivial element turning the free group on two generators into a free abelian group on two generators. The powers of $g$ don't introduce any new relations, so we are done.