When I was a beginning cookie baker/decorator, there were two consistencies of frosting for every cookie; dam frosting and flood frosting. You don't have to be a rocket scientist to figure out that the thicker frosting was used to create a dam around the perimeter of the cookie to hold back the thinner, flood frosting. Dam frosting was mixed up as thick as toothpaste and applied to the cookie with a frosting bag. Then you would thin down the "toothpaste" to glue consistency and spoon it into the dam. This left a noticeable ridge around the edge of the cookie indicating where the dam ended and flood started. One problem was, it was easy to get the flood frosting too thin and then a bunch of air bubbles would appear in the surface of the cookie. It was only when I cut out a step and made my "thicker than glue, thinner than toothpaste" style frosting and applied all of it with a piping bag that my cookies improved.
Typically, we dam with a #5 tip. It is nice and thick and if it is applied well, will hold a fair amount of frosting on the top of the cookie. I don't usually want to use a very thin tip for daming because it would hold less frosting. However, there are times that call for a #3 dam. The first I can think of is when the cookie real estate is small and the border needs to be well defined. The other thing is when your dam needs to have sharp corners. Think about Varsity letters. That innocent looking M has about 10 angles that need sharp corners. Damming with a #5 is going to flow into rounded corners instead of sharp corners. Rounded corners on Varsity letters makes the frosting application look jacked up!
Cookies are all frosted with writing tips. The smaller the number, the smaller the hole, so the more pressure that will be required to create a stream. When we have a lot of cookie real estate to cover, we want a larger hole so that we can flood the cookie more quickly. The more detail we add to the cookie, the smaller the tip needs to be. Then there is a tipping point to every cookie. That is the point at which too much work (colors/details) is added to something that somebody is going to chew up and swallow (see Size 24 bikini).
Just remember, use a larger tip like a 5 or a 7 when you have a lot of cookie real estate to cover. Use a 2 or 3 when you want details. Use a 1 when you have nearly lost your mind!