mAh stay the same when you connect cells in series - provided that cells are all of the same mAh capacity.
Special and unusual case If two cells are connected in series and they have differing mAh capacities the effective capacity is that of the lower mAh capacity cells. This is not normally done, but it can sometimes make sense to do so.
mAh add when you connect cells in parallel (but there are technical issues which mean that doing this may not be straightforward.)
The answer can be deduced by considering what mAh capacity means:
mAh = Product of ma × hours that a battery will provide.
While there are (as ever) complications, this means that eg, a 1500 mAh cell will provide 1500 mA for one hour or 500 mA for 3 hours or 850 mA for 2 hours or even 193.9 uA for one year ( 193.9 uA x 8765 hours = 1500 mA.hours).
In practice the capacity of a cell varies with loading. A cell will generally produce its rated capacity if loaded at its C1 = 1 hour rate. eg 1500 mAh = 1500 mA for one hour. BUT a 1500 mAh cell loaded at say 5V (5 x 1500 = 7500 mA = 7.5A) will NOT do this for 1/5 hour = 12 minutes - and may not produce 7.5A at all even on short circuit. A load of say C/10 = 150 mA or C/100 = 15 mA may produce more than 1500 mAh overall BUT a load of say 150 uA = 10,000 x as long = 10,000 hours = about 14 months may produce less than 1500 mAh if the battery self discharges rapidly with time.
If a cell will produce say 2000 mA for 1 hour at 3.7V (a typical rating for liIon 18650 cells) then two identical cells will do the same thing if tested independently. If instead of using 2 loads you connect the cells in series and draw the same current as before the identical current flows through both cells. You can still here only draw 2000 mA for one hour BUT the available voltage has doubled.
If you use 2 x 3.7V, 2000 mAh cells in parallel to drive a 3.7V nominal load, one cell can provide 2000 mA for one hour or 200 mA for 10 hours etc AND the other cell can do the same. So the mAh ratings add.
If one cell has more mAh than the other, the mAh TEND to add when connected in parallel. Say you have 1000 mAh and 2000 mAh cells in parallel, each rated at 3.7V nominal, as the smaller battery loses capacity it will tend to reduce in voltage faster so the larger battery will provide more current so they will TEND to balance. YMMV and this is usually not good practice without specific design of what happens.
In the special case I mentioned above, you may have a 12V 7AH sealed lead acid "brick" battery beloved of the alarm industry. You may want to use an N Channel high side switch which needs a gate voltage of say 4V above the +12 rail. If you use a 9 Volt PP3 "transistor radio battery" and connect its negative terminal to +12 V then the PP3 positive terminal will be at 12+9 = 21 V initially. The N Channel MOSFET needs 12+4 = 16V so the PP3 + SLA combined followed by a regulator will operate it until the combined voltage falls to under 16V. This should be never happen, as the PP3 "dead voltage " = 6V and the Sla should not be under say 11V so minimum Voltage available = 11+6 = 17 V.
If you use this occasionally, and disconnect battery when not in use, the PP3 will last a long time. If the PP3 is rated at say 150 mAh, and if the FET high side cct takes a steady 10 mA when oj then the PP3 will last for ~~= 150/10 = 15 hours. This may be acceptable or not depending on the application.
BUT the SLA has a 7Ah = 7000 mAh capacity BUT the combination can only provide 150 mAh at >= 17 Volts. So the mAh effectively is that of the much smaller PP3. This is for the task which needs the combined voltage - the 12V output still has the full 7Ah capacity.