#1 root cause for what you describe is the 80A relay. Common fault. It is near the battery under the rear seat in most e34s, but on M20 and M50 powered cars it is in a big black plastic case on the frame over the front spring support. These fuses can die with age and look okay, and intermittently fail as well. Check the fuse on the firewall and also for inline fuses on the thicker wires that come from the battery. There may also be one under the backseat, I can't remember.
However a common fault causing such gremlins that any e34 owner must be aware if is water. An older e34 may have had windscreen replaced, have rust around the window (rare, it is only caused by windscreen repairers using bad tools and leaving bare metal to rust in the wet spots around the window). Or it cna be a blocked sunroof drain which causes water to seep in down the turrets, and secretly end up soaking into the foam under the carpet. An e45 can carry 50L of water in the carpet without you knowing. Danger signs are excessive condensation on the inside of ANY window in the early morning.
Check that the entire area under the rear seat is clean and dry, and free of rust around the connectors *underneath* the Relay Module, General Module, and Relay case. If you have water under there check the wiring loom- it may need replacing as corroded connectors are not easy to troubleshoot or repair.