2002 forester auto cannot put in gear

Hi,
I have a 2002 Foreter S automatic for one year. It was running fine all the time. However, a few month ago, one day when I put in Drive gear, nothing happen. The reverse gear was ok. After restarting, shift back and forth. It started working. And it happened a few times in a week or two. I search online, found maybe because it did not have transmission fluid. So I add a bottle of transmission fluid. Then next few month, everything was good. About 2 month ago, I drove it for a while and parked in front a store. After I coming out of the store, it had the same problem. After more than ten minutes shifting, restarting, waiting, it still did not work. I checked the transmission fluid level, it seem ok. I added half bottle of transmission fluid anyway. After a while and restarting, shifting later, it was working again. 3 weeks ago, same thing happened, after I drove 60 miles, then parked for 2 hours. And 5 minutes later it was working. Yesterday, the problem happen again. The transmission fluid level was ok. And after 10 minutes, it was working.
In the last few month, it also happened a few times that, during driving, after stopping at red light or highway ramp, without engine turn off or restarting, when push gas pedal, the car would not move as if not in gear. Then about half a second to a second, it got in gear by itself.

What do you think the problem is and is there a quick temporary fix (one or two month) before I find a new car? It really worry me that I one day it might not be able to run while I was on highway or outside alone.

Thanks
wp

PS, the previous owner seems taken good care of the car and did all maintenance at original dealership. The first time I had the transmission problem, the fluid level was very low. But since I then after I added fluid, the fluid is always clean and full (or maybe more than full).
Do you think a flushing of transmission fluid would help some at this point?

Sounds like either a bad connection on the shift sensor or the shift sensor itself. Secondary possibility could be simply loose shift linkage.

In my opinion a transmission flush never helps a transmission. Drain, replace filter and refill with the proper transmission fluid is the only way to go.

@wp

Are you sure the previous owner used the correct Subaru ATF?

Are you using the correct Subaru ATF?

How many miles?

How many miles since last fluid and filter service?

Don’t overfill the transmission fluid. No good will come of this.