How is a grammatical rule applied if the variable is not part of the source word
When we write $a^n(BC)^n$, we mean the word composed of $n$ copies of $a$ followed by $n$ copies of $BC$; using $^n$ is just a shortcut. For example, $a^2(BC)^2$ is shortcut for the word $aaBCBC$. Indeed, $^n$ just doesn't belong to the syntax of words, which states that a word is a sequence of terminals and non-terminals.