A longer rifle barrel does not make a rifle more accurate from an internal ballistics standpoint. The quality of a barrel however does. What a longer barrel will give is more stability in a shooting position due to weight and fulcrum balance. A longer barrel will give higher velocities and that enables one to work up a load in a larger velocity range. Accuracy or "tighter groups" can be graphed in relation to velocity increases. This graph will look much like a sin wave and a node in the same place on each wave having tighter groups. (aka groups get bigger and smaller again with velocity increases)
Example .308 cal:
Shoots sub MOA groups at 2300 fps and again at 2425 fps and again at 2550 fps and again at 2675 fps and so on
The groups open up 1 MOA + at 2375 fps and 2500 fps and 2625 fps and so on.
Now this is just an example, every barrel differs and must be tested itself. What is happening here is, at certain velocities and pressures a barrel closely matches the harmonic from another velocity meaning the barrel itself is moving or flexing almost the same way as pressure and bullet influence it. Having a larger velocity range to work in, one can really fine tune accuracy. Now how many folks really do this load development other than bench rest guys? Take a 20" barrel at a known distance you can ring steel all day, use it for UKD shooting not so much.
The other factor that really does influence accuracy per say, is a bullets ballistic coefficient (BC). The faster one drives a bullet the higher the BC, when a manufacture publishes an optimum BC you will be hard pressed to actually achieve that number, some bullet manufacturer's do give a range of velocities and a BC number accordingly. For long range rifle marksmanship higher BC means less wind effect, and the wind, my friends, is the biggest variable compared to any others in this equation.
My custom .308 rifle will always be 25" from lug to muzzle.