as I understand it...
The reason that pressure drops after a few inches (this is my understanding of the process mind you) is because the "chamber" created by the bullet seal, the barrel, and the case is getting larger (once the powder is burned, the chemical reaction that produces the pressure is over - the peak occurs at about the moment this occurs). Pressure drops after this because the gasses are confined in an increasingly larger "container" as the bullet travels down the barrel (ever-increasing volume of the "container" + the same volume of gas = lower pressure). Of course a certain length of barrel is needed to gain the optimum pressure
and to stabilize the bullet.
Of course what I have just written is purposefully over simplified, but this seems to be consistent with what I have read / reasoned on the subject. In short, choosing a powder with the right burn rate should theoretically allow you to gain the highest safe pressure given the barrel length chosen and other factors that I mentioned before. In a way, you can notice some 'evidence" for this when you take mild .38 spec. loads and fire them from successively longer barrels. The efficiency of the round is dependent on certain parameters. For example, my mild paper-punching handloads show significant velocity gains when I move them from a 2" to a 4" or 6" barrel. The rate of increase is about the same, but not only are both fired from revolvers (vented "containers) but the same rate of "gain per inch" is nowhere to be had from my Marlin carbine.
My mild .38 loads that I just described are optimized for a 4" revolver. I try to get a complete burn in that amount of barrel. When I fire them in shorter barrels, I get lower velocity (of course) and I can find unburnt powder in the barrel. This is especially true for my 10mm loads optimized for my 6.5" S&W 610 when fired from my Glock 29 (complete burn in 610, unburnt powder remaining in G29). Anyway, of course even these same .38 loads certainly get a velocity boost when fired from my carbine, but this seems to be due to the fact that the extra time they get the "push" from these gases more than compensates for the extra friction...but (here's the rub), the friction does take its toll....(continued below):
Again, I reason that the "gain per inch" in velocity from the carbine is much lower that what one sees when comparing 2, 4, and 6 inch revolvers (again, using my mild loads) since the amount of gas produced in the first 4" or so is from the complete burn cycle and the remaining barrel serves only to provide more time for this every-weakening, but still present "push" to accellerate the bullet & also "some" friction/drag (working against the accelleration, but not overcoming it). IF HOWEVER I were to instead change my .38 spec recipe (which I have done on more than a few occasions) to a slower powder for instance, this would allow the burn to continue though say the first 6-10 or more inches of barrel. More pressure would be produced (bigger push down the length of the barrel with less "extra" barrel at the end) and higher velocity gains would result....but, these new loads would likely not work as nicely in say my 4" revolver because doing so would result in lots of flash/flame out the end of the barrel and more (unburnt) powder speckling on my close-range targets.
That all said, I am more than happy to hear other theories - it's just that this is how I understand it to work. Did I explain myself more clearly this time?
***edited to catch *some* (though probably not all) typos.