There are many different ways to handle this, and not knowing the version of RPGMaker you have, all I can offer is something less than psuedocode. Ideally, you want an event other than the 'trap event' to handle the resetting of the trap. So create two events. The first event is the 'trap event' and is the actual graphic of the trap. The second is the 'handler event' and is an invisible event that is off the area of the map where the player can move. Here is what you want to do:
For the 'trap event':
1) Set the trap at it's starting location. Remember the X and Y coordinates of that location, called the 'trap starting location'. You may or may not put them in a variable.
2) Set it's movement to automatic, one space to the left (or right), with 'ignore impossible movement' checked.
3) Set 'trap event' to trigger when 'Event Touch' (or if using RPGmaker 2003, use 'Collision with Hero'). This will ensure that the trap is triggered when the player and trap touch, not just if the player touches the trap.
4) In the list of event commands for the 'trap event', code in your effects for getting hitting and teleporting back to the 'player starting location'. You may or may not put that in a variable.
5) Now if you play your map, you will see that the trap moves ONCE, sending the player back to the start of the dungeon if it hits. You are halfway done.
6) Go to the map and write down the X and Y coordinates of the area where the trap should 'reset', the 'trap ending location'. The X should be different, and the Y should be the same as the values in 'trap starting location'. This is the 'trap ending location'. You WILL need a variable for this, let's call it 'trap current location'.
7) Go into 'handler event' and set it to 'Parallel Process'. For the list of event commands, enter the following (this is psuedocode, so exactly what you enter depends on the version of RPGMaker):
variable 'trap current location' = sprite 'trap event' x coordinate
if 'trap current location' >= 'trap ending location' (if moving from left to right...or =< if moving from right to left)
[*]set position of 'trap event' to 'trap starting location'
variable 'trap current location' = 'trap starting location'
8) Test your game. The trap should reset when it reaches the end of its run.
You may ask why you set the 'trap current event' to 'trap starting location' after teleporting the event? The reason is to ensure that, as unlikely as it can be, that the trap doesn't reset as soon as it resets. I've seen this problem with the game engine only happen with certain early hacked versions of RPGmaker 200 and 2003. More than likely, that last line of code is not needed.
If you're saavy, you can extend trap's movement beyond the walls of the 'dungeon' by one a piece to make it look like the trap is coming out of and going into the walls. This is more complex, and I'd urge you to experiment with it yourself so you can better learn event-scripting.
Good luck!