You CAN diagnose this on your own, but it is a little tricky with a steep (not quick) learning curve. A great tool for this is called OBDFusion which is a phone app. You also need a wireless OBD2 reader.
Here is an excellent post from the E46 crowd:
https://www.e46fanatics.com/threads/obd-fusion.1240733/
If you are running lean, it's usually due to a vacuum leak and there are literally maybe 12 different ways you can have a vacuum leak on an M54...a rip in an intake boot is an obvious one...But a smoke test is a good way of finding vacuum leaks.
If you are running rich, It could be a bad MAF sensor or leaking fuel injectors, or too much fuel pressure...But don't just throw parts at it.
I saw your other post regarding a sunroof repair. You should find a competent non-dealer specialist and just pay the man to figure out your fuel trims.