The definite article before nouns mentioned for the first time
I've been taught that when one mentions an object for the first time and it's countable, one should use a/an before it. I know that there are exceptions, when you speak of a renoun object which everybody knows, like the moon.
But I cannot see why the author uses definite articles in some places in this piece:
"It had better use THE advertisement with THE shirtless guy rather than THE shirtless girl."
That ad/guy/girl were mentioned in the text for the first time. Why does the author uses the definite article before them? And could you please provide some rule which would clarify the usage of articles for me?
You were taught wrong. (Or at least you were taught a rule that works much of the time, but doesn't always).
You use the definite article when you are referring to one specific item. Obviously "the moon" is a good example, but in your case there is (presumably) only one advert with the shirtless guy. Therefore you use the definite article. It doesn't matter if you are referring to it for the first time. It also doesn't matter that there may be many advertisements - there is only one with the shirtless guy, so that is the one we mean. The second part of the sentence qualifies the first.
Similarly there is only one shirtless guy and only one shirtless girl in the advertisements we are considering, so they also get the definite article.
If there were several advertisements with the shirtless guy the first article would become indefinite. If there were several shirtless guys the second article would become indefinite. If there were several shirtless girls the third article would become indefinite.