there are dozens of things which can cause safe mode
usually it is an internal mechanical issue in the transmission or low fluid
it can be a failed sensor / solenoid / other small component or an electrical issue
there is no way to know until detailed computer and manual diagnostics are carried out.
a simple plug in of a basic scanner will not determine the cause, you will need to invest in high end diagnostics on a factory BMW scanner
again, there are MANY things which can cause this and usually it is not electrical. it is impossible to say until the detailed faults are read out and further hands on checks and tests made - chiefly a fluid check.
Sorry if you were hoping for a different answer, please don't shoot the messenger - I can only give the honest answer, which I have. Please remember that a low rating PUNISHES me for my honest and prompt response, and I receive nothing for my time and answer until a positive rating is clicked.
Please let me know if you have further questions. Please do not forget to click a positive rating as this is the only way I receive credit for my answer, thank you. Best wishes with your vehicle.