I'm having some trouble understanding how surgery again produces a smooth manifold. My understanding of surgery is something like this:
start with a smooth manifold $M$ of dimension $m$ and, suppose we have an embedding $S^k \times \mathbb{D}^{m-k} \to M$ for $k < m$. Setting $U = S^k \times $int$(\mathbb{D}^{m-k})$, we take $M \setminus U$ and attach $\mathbb{D}^{k+1} \times S^{m - k -1}$ along the boundary $S^k \times S^{m -k - 1}$ of $M \setminus U$. I'm fine with this, and it's clear to me that I get a topological space which has a smooth structure everywhere, except along $S^k \times S^{m - k -1}$. But I'm not sure what to do with points sitting along the boundary or what a smooth atlas around such a point looks like.
I've tried working out a fairly simple example: suppose that $M$ is a disjoint union of two circles, say $M = S^1_+ \cup S^1_{-}$. I select a point $p_+ \in S^1_+$ and $p_- \in S^1_-$ and neighborhoods $\mathbb{D}^1_+$ and $\mathbb{D}^1_-$ around the points. I then obtain an embedding $S^0 \times \mathbb{D}^1 \to M$. Removing the neighborhoods, I obtain two circles with a small arc missing around the two special points, and then I connect the endpoints of the arcs by lines. The problem is of course that I have these 4 points where the space isn't smooth; I could easily smooth them out in this case (everything is sitting in $\mathbb{R}^2$ anyway, so it's simple to write everything down and then obtain a homeomorphism from this space to a smooth manifold); however, in general, how do I place a smooth structure on a space after surgery so that it's still a smooth manifold?
One way how to do it is described in Kosinski's Differential Manifolds. For the simplest case of connected sum (that you describe with the two circles), you choose two diffeomorphism $h_i: \mathbb{R}^m\to U_i\subseteq M_i$ for two disjoint manifolds $M_1, M_2$. Choose an orientation reversing diffeomorphism $\alpha: \mathbb{R}^m\setminus\{0\}\to \mathbb{R}^m\setminus\{0\}$ that maps neighborhoods of $0$ to neighborhoods of $\infty$ and vice versa. The connected sum of $M_1$ and $M_2$ can be then defined as a disjoint union of $M_1\setminus \{h_1(0)\}$ and $M_2\setminus \{h_2(0)\}$ by identifying $h_1(v)$ and $h_2(\alpha(v))$. It can be shown then that this defines a differential structure independent on the choice of $\alpha$. You don't need the ambient space ($\mathbb{R}^2$ for your circles) to define this.
A similar construction can be done for attaching more general handles, see Chapter 6 (Operations on manifolds)