In the first sentence, I know that 了 is the completion marker (了1)
which can come after the object if the object is short and the
sentence is simple.
That sentence is a useful rule of thumb to try to simplify a very complex issue; however, it does not really get to the heart of what is going on with 了. The problem with 了 is not actually grammatical or syntactical, it is semantic and pragmatic. What we Chinese learners often misunderstand is that the use and placement of 了 affects the meanings and pragmatics of statements, not really the grammar.
Here are my thoughts as a student of Chinese syntax. You will need to ask native or advanced speakers for actual usage questions that go beyond surface syntax and semantics.
The other problem is that the use of 了 is actually fairly simple from a Chinese point of view. The complexity comes from the total and complete mismatch with how English works. The complexity is actually on the English side of things on our tendency to try to see Chinese through an English lens.
First, we have to understand what 买衬衫 actually means. We might translate it as "to buy a shirt/shirts," but actually means something more like "engage in shirt-buying." The reference to shirts is generic. In normal English, we a required to specify the number and add the indefinite article to the singular. In Chinese, no more detail is required or even desirable if that is not yet the focus of the utterance.
If the very next comment were to be about some specific shirt or shirts, then 买一件/一些衬衫 would be a better way to establish particular shirts as the next topic. English speakers might think, "This option is great! If I know how many shirts are involved I can say so to be on the safe side and be more detailed. But this is not how language works. On leaving the house, we do not normally say things like: "I am about to go to the store across the street in this city in this region in this country on this continent on this planet, etc. The extra detail actually diverts from our message rather than enhancing it. It's usually better and actually more pertinent to say "I'm going to the store!" if your purpose is just to keep others in your house updated about your activities and location. The purpose of saying 买衬衫 is to contrast it with some other activity, like dancing, playing chess, or even buying shoes. You only add detail if that is specifically what you want to direct your listener's attention to at that moment.
Now let's talk about time in Chinese. Chinese has a few ways to talk about how an action unfolds (such as the constructions with 在), but uses a different strategy for placing an event on a timeline. As you probably know, Chinese is called a topic-comment language. Grammar books underplay how radically different this makes Chinese from English. Because of this feature, Chinese can address time in either the topic or comment or both.
To locate an overall action in time, Chinese puts a time reference at the beginning of the sentence or clause, where topics go. The time reference could be a time word like "yesterday" or "at 3:45," but can also be a clause like "after eating" or "before I got up." On the other hand, Chinese uses the comment part of a sentence or clause to tell how far to move down the timeline and focus your attention on a particular stage of an event or series of events.
Chinese is much more specific about separating the stages of events than English. Because of this, it has very few or arguably no single character/words that actually describe more than one stage of an event. That is why Chinese usually needs two-word equivalents for words like "find" and "see."
The phrase 买衬衫 only describes one stage of things; so if you say 昨天买衬衫, you are only describing one stage of things and inviting your listener to envision the stage of "shirt buying." This is a good expression if you want to translate an expression that includes "was buying shirts" or "as X was buying shirts" or "there was some shirt buying (for a time)." If, however, you want the listener to envision the aftermath of shirt buying, you need another expression. The most flexible one is simply 了.
The particle 了 expresses the boundary between two situations or two stages of one action. If the expression before it is interpreted as a stage in a chain of events, then that expression refers to the stage prior to what 了 refers to, as in 起床了 (got up (from bed)). The two stages are rising and then being up. If what goes before it is interpreted as an ongoing situation, then that expression describes the second emerging situation expressed by 了， as in 下雨了 (it's raining (now)). The new stage is the change in expected weather, which is now characterized as being rainy.
The particle 了 used at the end of a sentence, by being vague/flexible, also invites the listener to consider the implications of the new situation or the aftermath being described; so that in addition to merely indicating time, it can also convey additional implications that we might express in colloquial English by adding "you know" or "you see" to the end of an assertion. It can also convey a sense of updating the listener on the situation as a whole.
By adding 了 after 昨天买衬衫 to get 昨天买衬衫了, you are inviting the listener to imagine a moment in the aftermath of shirt buying. This is a good way, for instance, to describe how "yesterday" ended up: "there was shirt buying, and then other stuff" or "he engaged in shirt buying" or "he bought a shirt/shirts, (you know/see)." You would not add 了 if your next utterance was to describe something that happened while you were buying shirts, because it would focus the listener on the wrong stage of the action. That is why whether you use 了 to translate "bought shirts yesterday" depends on your overall speech intention not the actual facts of what happened. In other words, what moment in time do you want your listener to imagine and how far down the timeline do you want to go?
How about 昨天买了衬衫? This is perfectly grammatical Chinese, but it is quite odd out of context. Here 了 is internal to the activity and appears to try to describe the second stage of "shirt buying," and yet we don't normally think of such expressions as having two stages. It is a very specific time reference in an expression that is vague about time. The expression becomes fine and normal if we use it as a time expression to express the first stage in a sequence of activities as in 昨天买了衬衫就回家了. Here the reason for 了 becomes clear, since it marks off the boundary between two stages: buying shirts and returning home. Without the follow-up clause, 天买了衬衫 tends to sound like you are trying to express a two stage event without yet getting to the second stage. It sounds unfinished.
You can also use this internal 了 (with such generic or simple objects) if the expression has context that makes it already part of the discourse and/or has a very specific reference. An example would be 他在美国发了财 (He got rich in America). Here, there is a strong contrast between the first stage of contemplating getting rich and the second stage of actually getting rich, so the 了 is necessary to express the latter meaning. You want to express where "getting rich" was achieved not merely describe what the nature of the activity was.
More common yet is to add 了 when the object and its status is more salient apart from the activity itself, such as in 买了一件衬衫. Without 了, you imagine the shirt on the shelf. With 了, you imagine the shirt in the shopping bag. If your purpose is to explain how many shirts ended up in the shopping bag, you need 了. If, on the other hand, you just say买衬衫, the number and condition of the shirts is left unimportant, flexible, and vague. The speaker wants to stress the activity more than the shirts themselves.
If you say 买了一件衬衫了 with two 了s, they act independently to create a combined meaning. This expression means that having a shirt in the shopping bag has ongoing implications or is the first stage in a series of situations referred to by the second 了. It could be an equivalent of "bought a shirt so far," but other meanings are possible. Using two 了s with numbers is a good way to describe an ongoing count. The first 了 expresses the stage that the count has reached, and the second 了 implies that there are other stages or situations to come. Outside of this context, it is rare that you would use or want to use two 了s.
Now we can deal with 买了衬衫了 more clearly. It is a very specify grammatical expression applied to a very vague situation, leaving its meaning highly contextual. The first 了 conveys something like "getting shirt buying done" is the first situation to consider, and the second 了 implies that this action has ongoing implications for the emerging situation or creates a second situation. It might mean "got shirt buying done, so far/you see/you know" or "actually did buy shirts, so far/you see/you know." It is rare that you would want to convey such a pragmatic meaning and more common that only one 了 would be used; nevertheless, such expressions do crop up every now and then in appropriate contexts. You also have to consider that there are other ways to add meaning that might be even more appropriate to the situation and more common, such as 他把衬衫买到了, which tells you what ended up happening to the shirts and where things ended up.