You can check out my thread on this exact problem. I was fighting this for weeks.
Try this: Remove the right-rear light cluster from inside your trunk. Unplug the connector and check for dirty or burnt connector pins. If there was a bad bulb in there, it could have shorted and made a bad connection from the burning, etc. (That was my problem).
Also, take a small, flathead screwdriver and gently pry the contacts for each bulb (on the cluster) upward. They operate as a spring when the bulb is pressed down into their respective sockets. If the contact isn't pushing enough against the bottom of the bulb, then your car will not get a good, solid signal from that bulb all the time, and it my "think" the bulb is going bad. While you are doing this, also take the screwdriver and scratch the surface of each of the contacts where the bulb touches them, to ensure a good contact connection.
That, with scraping out any corrosion from the connector and pins should do the trick. If not, then tripple-check that you have the correct bulbs in there. (1156 bulbs).
Best of luck!
2002 BMW 325i