I think (so this answer is not purely objective) nothing is totally obvious about some rules which may lead to some conclusion.
Starting from the simple definitions provided here, we have three meanings:
The non familiar and literal one: each time a stroke is given
A first familiar one, but close to the previous as "coups" here has some kind of 'generalized' meaning: à chaque fois
A second familiar one which means "certainement" and is similar to "à coup sûr". Note that "certainement" as itself two meanings: a pure certainty and something that we are quite totally sure of. "A tous les coups" is relative to this second meaning.
Surely, the first clue is provided by the overall context: can something be uncertain or unknow in this context?
For instance, in a narrative form like
"Sophie avait une admiration folle pour lui. A tous les coups, elle essayait d'imiter ce qu'il faisait. C'était devenu une obsession."
there is nothing doubtful. All is said like facts. So that "à tous les coups" cannot be "certainement", even if placed at the beginning of the sentence.
Secondly, comma or pauses that separate "à tous les coups" from the other part of the sentence can be an indication, so that we can guess:
"A tous les coups, elle fait cette chose" is "certainement", like a comment about the overall sentence. But sadly (for us here), this separation can also be a way to highlight or give an importance to "à tous les coups".
"A tous les coups elle fait cette chose" sounds much more like "à chaque fois" as linked to the verb.
Same thing if placed at the end:
"Elle fait cette chose, à tous les coups" (certainement)
"Elle fait cette chose à tous les coups" (à chaque fois)
And if placed in the middle, I think this is the same principle, except that the sentence becomes more complex, so that the overall tone sounds less familiar:
"Elle fait à tous les coups cette chose" (quite surely "à chaque fois")
"Elle fait, à tous les coups, cette chose" (may be "certainement" but sounds less obvious)
Concerning the provided examples, two elements are blurring the meaning a bit:
"Sophie a une admiration folle pour lui" does not sound as a familiar way of speaking. So we are intuitively closer to "à chaque fois".
"tout ce qu'il fait" can be itself interpreted as "each time a thing is done" which reminds "à chaque fois".
but over that, I think the use of the comma is the main clue in the sentences given in your question.