Machining and metallurgy. I doubt low cost rimfire rifles have certified steels used for the barrels, but I don't know that. Machining, tooling, coolants during machining, heat treat, harmonics. Change anything and you can change accuracy. Same thing with reloading, I just started reloading and I haven't got into reloading for accuracy in a specific firearm, just general range ammo. But I see guys saying they make minute changes in powder, powder amounts, bullet seating, etc., and change a 2" group to an, all rounds touching group. Same thing with manufacturing.
I have a Remington 597 I bought on sale at Bass Pro in 2005. It was a "package" deal with a scope from the factory. When I got there, they didn't have any of the "package" guns left, so they put a $40 House brand Redhead scope on it. I bought it for a plinker.
That gun is very accurate, dime sized groups at 25 yards all day long. (I've only shot it at an indoor range) My BIL wanted a rimfire and I sold it to him, luckily I got it back.
I've had feeding problems with most rimfire ammo, with the exception of CCI Mini Mag. It works in everything I have used it in. Here is something I find unusual… Mini Mag hollow points are more accurate for me than round nose. You would think it would be the opposite.
However…. The shooter is absolutely more important than anything. I've seen guys question the accuracy of a rifle or scope, that couldn't hit the side of a barn if they were standing in it. No matter how much money you spend, it can't overcome a person that is a crappy shot.