1. They can understand new commands after only a few times.

(Does 'only' modify 'after a few times'? noun phrase...)

2. They understand new commands only after about 100 times.

(Does 'only' modify 'after abut 100 times'? adverbial phrasse...)

Yes, in both sentences, you have "only" in the right place for the very reasons you have written. Nice!

To determine the role of the word "only" in a sentence, we need to identify the word or phrase it is modifying. In the first sentence, "only" modifies the noun phrase "a few times." To confirm this, we can rephrase the sentence: "After a few times, they can understand new commands." It implies that they have a quick understanding after just a few instances.

In the second sentence, "only" modifies the adverbial phrase "after about 100 times." We can rephrase the sentence as: "They understand new commands after about 100 times, not before." This implies that it takes a considerable number of repetitions before they can understand the commands.

In both cases, "only" is used to emphasize the limited number of times required before comprehension is achieved.