engine reving up on my 94 325is

I have a 94 325is. I replaced it with a new engine that only had 60K miles on it when I first bought it last year. Drove it for 3 weeks then it just wouldn't start. Brought it back to the mechanic and they said it needs a new central computer unit. I replaced that. Then the enjine started reving up on its own while it was idle. Brought it to another mechanic and they stated that it needs a new fuel pump. I replaced it with a brand new fuel pump. Now it is still giving me the same problem, engine keeps reving up on its own for a few minutes while idle and then dies after staying idle for a few minutes...could this be a relay, or some type of sensor problem??? I'd don't want to take it to another mechanic until I know for sure what the problem is. This is frustrating.