#update
I stand on the backs of giants, lol
Kudos to @potong for a great sorting solution with brace expension! That means this whole thing can be reduced to a single-process one-liner:
sed -i '0,/^AAA/{ /^AAA/{ s/AAA/ZZZ/; h; } }; ${ x; /./{x;q;}; x; }' chapter\ {[0-9],[0-9][0-9]}.tex
#edit
As pointed out, the original solution below would process and change the first occurrence in every file, and does not correct the file order. @anubhava already provided an excellent, elegant sorting solution on which I will not try to improve.
while IFS= read -r -d '' file; do lst+=( "$file" ); done < <(printf '%s\0' chapter*.tex | sort -z -V)
This creates a list of the filenames in proper order which can be passed to a single call of sed to process them en masse.
To apply that to ordering to a sed-based solution and only hit the first occurrence in any file -
sed -i '0,/^AAA/{ /^AAA/{ s/AAA/ZZZ/; h; } }; ${ x; /./{x;q;}; x; }' "${lst[@]}"
This will look through each file and change the first occurrence it finds in that file, holding the line where it first finds it. On the last line of each file it exchanges the current line for the hold buffer and checks to see if after the swap there is anything in the pattern buffer. If there is not, it swaps it back and continues. If there is, it swaps it back and quits, skipping all subsequent files.
While somewhat complicated, this does not spawn processes for each file.
Original
Use a double condition -
sed -i '0,/AAAAAA/{ /AAAAAA/s/AAAAAA/ZZZZZZ/ }' chapter*.tex
To see the same general logic in action:
$: cat a.tex b.tex
111
AAA
BBB
AAA
222
111
AAA
BBB
AAA
222
$: sed -i '0,/^AAA/{ /^AAA/s/AAA/ZZZ/; }' *.tex
$: cat a.tex b.tex
111
ZZZ
BBB
AAA
222
111
ZZZ
BBB
AAA
222
'0,/^AAA/ is right, as it ranges from the start of the file to the first occurrance of the target string.
{ opens a block, in which we can use a second search to make sure it only affects the targeted string.
Inside the block, /^AAA/s/AAA/ZZZ/; substitutes the AAA string and ignores all the records before it. } closes the block. All records after will be untouched.