What you fail to account for is the weight of each battery. If they are both the same C then obviously the 4S battery will be heavier. Your question is too simplistic. Take @amilcarlucas advise and invest a whopping $2.99 in eCalc and you can look at many scenarios.
.
E-Calc is great in terms of the computations and taking into account nuances!
If you want to understand more about batteries I will give a quick, but not complete summary.
1.) No, you will not get the same duration of flight out of a 3S 5000 mAh vs 4S 5000 mAh. The total energy stored in each battery is different as one has higher potential.
To compute: 3S (cells) * Nominal Voltage (V) * 5 (A-h) = 3 cells * 3.6 (V/Cell) * 5 (A-h) = 54 W-h
For 4S 5000 mAh -> Energy stored = 72 W-h
Note: I used 3.6V/cell for the nominal voltage but this is dependent on cell chemistry.
Generally, for flying vehicles an important metric is the gravimetric energy density.
IE: 72 (W-h) / battery_weight (g) : “just get more Ah” has finite returns due to weight
Next you find your thrust vs power curve given the propeller, motor, and voltage combo. You will see this info. for example here in the “Specifications” tab https://store-en.tmotor.com/goods.php?id=341
So for example if at 50% throttle gives you the thrust you need to hover with power use of 31W per motor.
A rough estimate of flight time is: 72W-h / (4 motors * 31W) = 0.58 hours
There are other consequences to a higher voltage as well:
All electrical components must be able to accept that higher voltage (motors, ESC, BECs, sensors, etc.)
At higher voltage things run more efficiently as to get the same power out you need lower current (A) and resistive losses are I^2*R dependent
However, the same motor will turn faster with 4S vs 3S which yes is more thrust… But this isn’t just as simple as “now I get more thrust and linear amount longer flight time.” You now could be operating your motor and propeller with far less efficiency and we didn’t take in account efficiency into anything above…
You can. Josh posted some good info above. There are several factors to consider as he noted. Also, there is diminishing returns with adding more capacity all else being equal. So the Flight time vs. capacity is not a linear relationship. And if the thrust/weight ratio is diminished then Flight Stability can be compromised.