HELP with Motor Shield

Hello friends …

I have a ARDUINO MEGA 1280 and 2 MOTOR SHIELDS to control 4 motors dc !
I’m maybe simple problem!
arduino shield in a pile and easily control the direction and rotation of two engines!
now when I connect to another shield, comes the problem!

I connected the pins 31,33,35,37 of the arduino pins 4,5,6,7 of my second shield and the shield gnd tb stacked on the second! external sources used to track shields!

blz!
engines ran into a sense now when I switch from high to low in the second shield, the engines stop!
only the engines of the first shield work!

what can be?

cod follows that I am using to test!

hugs

int E1 = 5;
int E2 = 6;
int M1 = 4;
int M2 = 7;

int E3 = 33;
int E4 = 35;
int M3 = 31;
int M4 = 37;

void setup()
{
    pinMode(M1, OUTPUT);
    pinMode(M2, OUTPUT);
    pinMode(M3, OUTPUT);
    pinMode(M4, OUTPUT);
}
void loop()
{
    int value;
    for(value = 0 ; value <= 255; value+=5)
    {
         digitalWrite(M1,HIGH);
         digitalWrite(M2, HIGH);
         analogWrite(E1, 255); //PWM Speed control
         analogWrite(E2, 255); //PWM Speed control
         delay(30);
         
   
         digitalWrite(M3,HIGH);
         digitalWrite(M4, HIGH);
         analogWrite(E3, 255); //PWM Speed control
         analogWrite(E4, 255); //PWM Speed control
         delay(30);
    }

    }