'06 Tribute O/D flashing light and Enging light on

Hi all.
have a quick question I have an 06 Mazda tribute. When it had around 30k miles it started flashing the O/D light and was not shifting gears normally. Since it was under warranty at the time, I took it to the dealer and they kept it for around a week to replace the transmission. Now it has 39k and it started doing the same thing but this time it also has a solid engine light on. This always happens under normal driving condition and now I am concern if the Transmission needs to be replaced.
Can anyone give me suggestion on what could be the problem? I cannot believe that in less than three years the car could develop the same problem. Would this really be the transmission and twice in less than 3 years and less than 40k miles?

I would appreciate your input with this issue and if some had gone through the same issue, I would appreciate if can give me some pricing idea.

Thanks in advance
 
Back