Little of this applies to the AR 15 and the like but reflect my experience with bolt actions.
As noted above, a lot of problems come from improper inletting, under or over torqued action screws, and things like that.
To see if you have a bedding problem, try getting either inletting fluid (midway or brownells), cheap lipstick, lampblack (very messy), or something like that to determine where your barrel and receiver are touching the stock. There are threads that will guide you to correcting barrel and receiver bedding problems here and elsewhere.
A few other issues--sometimes barrels, particularly thin ones, can be bent--quick visual check resolves that, action screws either under or over torqued--find the recommended torque for your model's action screws and apply that, magazine issues--some want separation from receiver (Mauser types) while others don't.--check forums for your model and its peculiarities, barrel bands if present can lead to inconsistency if too tight or too loose --forums are your friend here, stock warpage--determine through visual if bad or through inletting, and some barrels need downward pressure at the tip while others like to be free floated--trial and error with temp shims or free float the barrel.
BTW, a tip, pick one type of factory ammunition and bullet profile and stick with it throughout your troubleshooting. Switching factory ammo or using handloads when troubleshooting just adds more variables to the accuracy equation.
FWIW, regarding bolt actions--there is a significant difference between military and civilian rifles. Military rifles are generally overbuilt and aim for good enough accuracy rather than perfect. Militaries generally dislike parts that break easily and complicated designs. Thus, they are generally heavier than civilian rifles and can stand a lot of abuse that a factory model simply will not take. The downside is that you often have to spend a lot of time with military rifles to even get accuracy approaching a cheap off the shelf hunting rifle at Wally World and if left in military garb are much heavier than most civilian rifles (apart from benchrest).