Shell command SET -X mean in script

You can read the bash online manual for set:


Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.

So it does exactly what you described.

It's a bit hard to find but this is from the bash man page:

   set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
          Without options, the name and value of each shell  variable  are
          displayed in a format that can be reused as input for setting or
          resetting the currently-set variables.  Read-only variables can‐
          not  be  reset.  In posix mode, only shell variables are listed.
          The output is sorted according  to  the  current  locale.   When
          options  are specified, they set or unset shell attributes.  Any
          arguments remaining after option processing are treated as  val‐
          ues for the positional parameters and are assigned, in order, to
          $1, $2, ...  $n.  Options,  if  specified,  have  the  following
          -x      After expanding each simple command, for  command,  case
                  command, select command, or arithmetic for command, dis‐
                  play the expanded value of PS4, followed by the  command
                  and its expanded arguments or associated word list.

So basically it's a debug option. It does not only execute all the commands but also prints them before it executes them (to stderr).