What the problem could be 1997 Mercury Villager couple of weeks it started having this problem sometimes when you stop in a stopligth the motor begins to vibrate and the revolutions goes to 500RPM?

Transmissions are controlled by sliding valve rods...Their movement is either by transmission pressure or electro motors controlled by computers. Dirty fluid, low fluid in trans or gummy build up on these valves can prevent normal shifts including downshifts at stops, required to start smoothly away from the stop. If trans sticks in a higher gear instead of down shifting, it will shudder and shake just as a trying to start in 2nd or 3rd gear in a manual trans. Possibility that there is a locking torque converter that is not releasing though that would be my last possibility. Solution: When it does it, shift into neutral ...if it goes away, go back to D (drive) and see if it reoccurs. if it does, shift thru the gears (P- 2, particularly down to 3 and then 2. Check again. If that does not correct the shudder...May need a trans flush and change of trans fluid, a can of transmission tune-up (cheapest), but next would be to drop the pan and flush the valve body (R & R ?). Possibly, problem may be more related to computer / fuel system problems, but I am basing my answer on a similar problem with our 97. At some point, it makes sense to go to the dealer and hook it to the computer that can read these problems and give a computer diagnosis. Otherwise, you may be starting to inaccurately throw large sums of many at incorrect repairs.