Master doesn't receive the correct values in a master/slave SPI link
In slave, command is always 0. You problably meant:

void loop(void) {
    command = (digitalRead(SS) == HIGH ? 0 : 1);
}


and at ISR:

ISR (SPI_STC_vect) {

    byte input = SPDR;
    byte output = 0;

    if (command) {

        switch (input) {

            case 'a':
                //...
                break;

            case 'z':
                //...
                break;
        }
    }

     // send data back
     SPDR = output;
}


As a best practice, avoid to implement the logic within the ISR and use global volatile variables to pass state changes to the code in the main loop. Probably you will have to implement a circular buffer to receive from and send to the SPI bus...