As far as I recall, the capacity xxxx(xxxx), the code is that the second number is the baseline (this can be reduced say by damage to the rail yard) and the first is what is still available
so I'd agree with your first para.
If the depot is in a port then it keys off the port size not the rail yard, so that might be the reason why those are a wee bit larger (don't have the game open to double check so not sure). Alternative is the scenario designed over-rode the normal rules for some reason to get the game moving?
Blida and Constantine both display Rail: 10000 : 5000 even though they are inland, so I don't think ports are the issue. It's possible that the railyard factories have a side-specific production multiplier like some other factories, although I have not seen it mentioned in any documentation. If the Algerian railyards really need to have 10k capacity to make the scenario work, why not just use two factories per railyard?
More generally, basic idea is to show Rail: RemRyC : InitRyC, where InitRyC is the initial railyard capacity that the phasing player has available each turn and RemRyC is what remains after the player has moved some units by rail. If so, then each turn should start with RemRyC = InitRyC, and RemRyC should never be greater than InitRyC. This is in fact what the railyards show (Rail 5000 : 5000) when Torch to Tunisia is loaded into the WitW Editor, so the change to 10000:5000 seems to happen during the first Allied logistics phase.
According to the manual (5.2.1, p.31) "Rail: xxxx: xxxx: Displays in railyard hexes. The first number represents the amount of rail tonnage capacity remaining unused in the railyard. The second number reflects the damage adjusted amount of rail tonnage that can be moved by the railyards in the hex (set near the end of the logistics phase).
So in your example, the railyards in Tunisia they can generate 10k in rail tonnage capacity but accounting for damage only half is operational. That's my guess!!!
None of the railyards I mentioned are damaged. With only one railyard factory each, they should be producing 5k per turn and not 10k. Safi is 41% damaged, with the pop-up showing Rail: 5900 : 2950. The second number is what you expect with 41% damage, but the first number---which is what the player can use in Rail Mode---is again double.