I'm hoping that ceeyo's ground advise cures your issue. It's sound advise given that you removed the power cables to install the new battery.
However, given your code reader output I have a bad feeling that your issues aren't going to be cured with old school methods. In that, it's either the computer or the computer program which is preventing the starter from working.
I basically ran what was highlighted in yellow from your code reader on google and here is what was very like your issue:
https://www.bmwgm5.com/E46_EWS.htm