Most likely the bulb holders are the problem. This is a very common failure point on the X5. A 50k+ vehicle that uses cheap crappy plastic/metal fittings in the main light units that have been causing problems for years across all the model lines. (RANT OFF)
Take the units out and examine the contact points for the bulb holders and also the bulb holders themselves. Look for evidence of burning. Clean off the black residue and they should work. Some have used solder to build up the contact points and found it to help. I have used the conductive grease electricians use in meter boxes and had great success with it. I used it on the front turn signals and had no problems for 6 years. You might also consider the newer LED units as they really improve the look and visibility and eliminate the problem.