how to run code only once and not to loop on receiving a trigger.

i want to run a motor forward for 5 seconds, stop for 3 seconds and in reverse for 5 seconds when the gas sensor value reaches a target value. i want to run the motor sequence only once or a specified no of time and not to repeat. how this can be done. iam using h bridge l293d

Have a look at how millis() is used to manage timing in several things at a time

The demo controls LEDs but it could easily control a motor.

You need a variable to keep track of whether the movement has occurred so that it won't repeat inappropriately.

There are many examples that come with the Arduino IDE. Have a go at writing your program and if it does not work post your code and explain what it actuall does and what you want it to do differently.

...R
Planning and Implementing a Program