The main differences are that a longer barrel will accelerate the bullet projectile for a longer period of time and send it downrange at a higher velocity; and the longer firearm has a longer site radius (the distance from the rear to the front sight) making aiming more precise and errors in aiming more obvious.
The longer barrel also gives slightly more time for you to accidentally move the firearm off point of aim before the bullet is in flight. This means that you must develop your hold control and trigger control to keep shots on target.
Once you develop your handgun shooting skills, most people find they can shoot more accurately with the longer handgun. Accuracy of the gun itself can only be tested from a solid mount in a "Ransom Rest" which eliminates any errors a person might introduce. What I said above applies assuming the long and short barreled guns are equally accurate.
To expand on what the gentlemen above already stated but do it less eloquently ...
If you are using a rest, bench or even monopod or tree branch you may see a difference.
If handheld ... I personally find I shoot the 3-4 inch more accurately from an unsupported position even out to 25 yds because I can bury more of the gun in my meaty hands and feel like I have more control over errant movement.. Enveloping the gun makes ME more accurate with it. I owned for a brief time a 6" gp and to tell the truth I was worse with it because I found it a bit unwieldy.
You didnt say what you might be choosing a gun for so I thought I would chime in.
What mrerick said! In my experience, once you have breathing and trigger control in hand, longer barrels are more accurate for the shooter. Longer sight radius helps me take out some of my errors. Hank
Boriqua is talking about grip or hold control. Assuming you're not shooting from a fixed bench (which is more for testing the gun), your grip, stance and support of the gun contributes a great deal to accuracy. The longer the barrel, the more your contribution to accuracy matters.
Once you shoot a large number of handguns, you eventually work up to the point where anything you pick up can be shot accurately since you adopt the right grip, stance and support regardless of the design. Some are easier and more comfortable than others. Some are clearly preferred over others, but in all cases you do your best.
As an analogy, I know a concert organist who travels from church to church and concert hall to concert hall. Every single organ is different, and each one has flaws and quirks. His attitude is that he'll make them all sound good, regardless of how difficult they are to play. That ability comes with experience.
The main reasons I choose barrel length are the balance of the gun, and my intended usage. A six inch is, to me, a range gun unless I'm going to be out in the field and hunting. In the city, a six inch would be much more difficult to conceal carry, and less practical.
Having cataracts, the further the front sight is from my eye, the better. For me, lining up the bore axis with the forearm and tucking my head into the shoulder makes for better long distance shots. Irv has been kind enough to let me shoot one of his short barrel .38s and I was lucky enough to hit a 4" clay (once) at 100 yards...and he skunked me with my own 1911s in .38Super.
IMNSHO, breathing and technique et al contribute to long range accuracy, whether it's a 3" or 6" barrel.
Even a 1 7/8" barrel is long enough to stabilize a bullet, I've proven it countless times. As said above, a longer barrel gives a longer sight radius which helps but is only 1 factor in increased velocity. Chamber dimensions, barrel/cylinder gap, bore dimensions, rifling depth, type of propellant, etc. are also factors in velocity/bullet drop. The real thing about accuracy is technique.
My Father retired as a Southern Pacific RR Police officer in 1992 - he carried a 2 1/2" model 19-3 as his service weapon since ~1970.
He used to have fun on his annual Utah Peace Officer requals (at the Salt lake City/County Police range)... there was always some young buck who commented "you can't hit anything with a barrel that short". The veteran officers (especially those who had seen my Father shoot before) would just chuckle.
My Father regularly placed in the top 10% of those shooting, and often had the top score. The young bucks were always amazed.
He was respected enough that he was chosen to be on the team that designed their night-qualification course in the late 1980s.