Match the symptom first
The repair pages split no-start problems by what the car does when you turn the key. Weak cranking with a "battery discharge" warning is a battery problem. A single click with no crank, or slow or intermittent cranking with a good battery, is the starter. A long crank before the engine starts is fuel. This guide covers those three; for a battery that keeps going flat while the car is running, see the BMW Battery Keeps Dying: Alternator, Battery or Registration?.
Battery and registration
The battery page lists weak cranking or no start and an increased battery discharge warning as symptoms. Match the amp-hours and AGM versus flooded type. On late E90s and all F and G cars with the Intelligent Battery Sensor, registration is required after replacement, and if you skip it the new battery can be chronically undercharged. Start-stop may be disabled after a DIY battery swap. See Battery Replacement & Registration.
Starter motor
A single click and no crank, slow or intermittent cranking with a good battery, or grinding when starting are the starter signs. On the N52, N54 and N55 the starter sits under the intake manifold, so labor drives the price, and owners report 2 to 5 hours. Ask for a Bosch starter rather than the BMW-boxed part, which the page says is the same supplier for much less. While the manifold is off, owners often do the crank sensor or intake gaskets. See Starter Motor Replacement.
Fuel: the in-tank pump and N54 fuel system
Long cranking before the engine starts is on the in-tank pump page alongside stalling (often at low fuel), a drivetrain malfunction warning and an inaccurate fuel gauge. The pump is under the rear seat on F30, F32, F22, F10 and B46 and B48 cars. See Low Pressure Fuel Pump (In-Tank).
On the N54, a long crank or hard start comes with an "engine malfunction, reduced power" message, fuel pressure codes and misfires. Commenters recommend logging fuel pressure before replacing the high pressure pump because the low pressure pump can cause the same symptoms. See N54 High Pressure Fuel Pump & Injectors.
Charging and diesel notes
A battery that is flat because it is not being charged is an alternator question rather than a starter one (Alternator Replacement). On the X5 35d, the NOx sensor page lists a no-start countdown on the DEF system, so a diesel with a DEF warning and a countdown has a different cause than a gasoline car (NOx Sensors (X5 35d / Diesel)).