@PG is correct
To expand upon my point, I'm meaning that some operationally independent branches can need stock that is either a bit wasteful
For example, you might need twelve or thirteen units to maintain a service with a Peak Vehicle Requirement of ten - i.e. a maximum of ten trains in service at any one time - so roughly a quarter of trains unused to cover maintenance/ repairs/ repaints/ training etc - but the need for specialist stock on the Stourbridge line means twi class 139s dedicated to it when only one is ever in service - i.e. half of the trains are sat idle because there has to be some spare - you aren't going to naively assume that one unit will be indestructible and always be available for service - and with standard DMU/EMU carriages costing over a million pounds, having a branch that uses trains inefficiently costs a lot of money that has to be paid for somehow
Alternatively you can have a situation like the Marston Vale line (apologies for bringing up this lightly used line, but Forum tradition dictates that it gets mentioned on any thread that's over a hundred posts long), where the DMUs used in pre-230 days were common to LNW but didn't operate any other routes near the Marston Vale stations, so LNW had to arrange long ECS movements back to the West Midlands so that the 150/153 could be cycled in with the rest of the DMU fleet - on top of the reliability problem that a broken window on a unit on the Marston Vale would either see the branch reduced to just half frequency or trying to arrange for a driver and path down the WCML so that a 75mph DMU can come from Tydsley to Bletchley - quite the hassle
Sometimes the branch can become more uneconomical because of changes to the main line - e.g. the Thames Valley branches were able to use a large pool of 165s that Thames Trains/ FGW/ GWR also used on services to London/ Oxford etc. A big fleet can be more efficient in terms of the number of spares that you need to have. But with the electrification of the main GWML, that means fewer 165s based at Reading, which means any unit "spare" at Reading depot is only shared between a handful of diagrams, which pushes up the cost of operating the branches
But then is the alternative that you incorporate the branch line into the main line services, which can mean extending branch line platforms to accommodate trains the length of main line services and then use a lot more carriages as a result ... no easy answers!