The barrel's bore is not mounted correctly to the center line of the upper receiver.
As stated, could be as simple as debris between the upper barrel socket front face and the back mating edge of the barrel extension,
Or, could be that the upper receiver barrel socket and front face is not square to the upper receiver bore line, or the barrel extension on the barrel not square to the barrel bore line instead.
Checking for debris is easy by just pulling the barrel to check; as well as the latter if you have a lathe.
As for truing the upper receiver barrel socket, I have a Madel that I press into the upper receiver that will true the upper barrel socket channel if it was canted from over torque pressure when the barrel nut was installed. From there, the upper on Madel is chuck up in the lathe and if the front face of the upper socket needs to be trued, then quickly down as well.
Next comes the barrel and chucked up between two live centers lightly, use a indicator on the back bearing edge of the barrel extension to make sure that is running true to the barrel bore. Also allows you to check to make sure that the barrel is not bent as well.
Here if the barrel extension is not running true to the bore line of the barrel, then becomes a little harder cleaning that up, depending on how bad the run out and where.