This was a bit too long for a comment, so I am posting it as an answer. You are sort of asking two things:

How to turn your manifolds M and S into an appropriate manifold with corners together with an appropriate notion of collar?

How to then glue these to obtain a new manifold?

To do (1) you'll need some assumptions on S, probably including compactness. In many cases though it might be clear that you *can* choose such collars.
In that case you might be interested in Theorem 3.5 from my 2009 dissertation (arXiv:1112.1000, page 140). There I show that even if the collars are not specified, the glued manifold is still unique up to (non-canonical) diffeomorphism fixing S and restricting to the identity outside a neighborhood of S. In fact the construction shows that there is a canonical contractible family of these diffeomorphisms (and so there is a canoncial isotopy class of diffeomorphisms).

I used this to build one version of the 2-category of cobordisms, where you need to glue along parts of the boundary in the manner you describe, but where you also don't want to mod out by diffeomorphisms too early.

When S is a component of the boundary, you can find this result here:

James R. Munkres, Elementary differential topology, Lectures given at Massachusetts Institute of Technology, Fall, vol. 1961, Princeton University Press, Princeton, N.J., 1966.

I basically adapted this proof to cover the case of gluing manifolds along a portion of the boundary.

thiscase because as written, the questions are not duplicates: this situation has the added wrinkle of not gluing along the whole boundary (or a component of the boundary). (That said, if Kosinski does have it then I have no issue with close-as-duplicate.) – Loop Space Nov 30 '11 at 14:30