The bore of a rifle is grooved, which puts a spiral spin on the bullet for greater accuracy.
Rifling forces the bullet to spin, which allows it to travel straighter. The more lands and grooves a rifle barrel has, the faster the bullet spins and a faster spinning bullet travels straighter.
The length of a rifle barrel will affect the length of time the bullet travels straight after leaving the barrel. A longer barrel will normally allow the bullet to travel straighter further than a shorter barrel (assuming the same bullets are used). Keeping your rifle clean will also help your bullets travel where you aim them to go.