Your codes are not complete. There are ALWAYS 5 digits, the first is an alpha character (usually P, which denotes a Powertrain issue), followed by 4 numerals that usually have a zero or a one for the first character. If zero, then the code is a generic engine management code that means the same thing on all cars or trucks that can generate that code -- P0301 _always_ means MISFIRE, CYLINDER #1 -- and if one then the code is unique to BMW -- other makes can produce the same code, but the meaning might not be the same as assigned by BMW
You have P0171 and P0174, which mean LEAN, BANK 1 & LEAN, BANK 2. Lean is most often a vacuum leak where air is entering the system after the MAF. All air is supposed to pass through the MAF, but if you have a leak after the MAF, then air gets in that the MAF has not seen, and this causes the fuel mixture to be lean. There can be other problems, but a leak in the intake track is by far the #1 source of LEAN codes.