I was trying to understand the Eilenberg-Mazur swindle (which I learned about here) especially as it could be used to show that if $A, B$ are compact (topological) $n$-manifolds whose connect sum is $S^n$ (i,e. $A \# B= S^n$) then $A=B=S^n$.

The trick seems to make use of the fact that:

(1) The infinite connect sum (when properly defined) of spheres is a non-compact manifold with one end (indeed is euclidean space).

(2) The infinite connect sum is associative in that any placement of parentheses that are *not infinitely nested* does not change the infinite connect sum.

I was confused for a bit because if one allows for infinitely nested parentheses one seems to be able to get a non-compact manifold with an arbitrary number of ends. The idea here is that with infinitely nested parentheses one could add spheres "on alternating sides" and so produce a cylinder i.e. a manifold with two ends.

On the other hand, if one is looking at absolutely convergent sums of real numbers then it would appear that one can allow infinite nesting of parentheses without issue. Though I'm not clear on what happens for conditionally convergent sums.

My question is whether my intuition about what can go wrong with infinite nesting justified? (I am coming at it from a very geometric point of view which may be a problem). What is the right framework to think about when one is asking whether infinite nesting is possible or note? I could imagine there is some sort of abstract algebra/category theoretic context in which such things are studied.

I apologize if this is sort a trivial question but I haven't thought much about algebra in a long time. (P.S I didn't know how to categorize this question so made a rough stab at it).