You need a space between "a" and ]] in the second if .
More technically, [[ and ]] should be separate tokens, and the bash parser does not split the tokens into quotes or large punctuation.
I believe your source code for the string is equivalent to if [[ ${step[x]} = "a]]"; then if [[ ${step[x]} = "a]]"; then if this makes the problem more obvious.
source share