There are a large variety of variables that can result in misaligned sights on an AR, making diagnosis and detection a difficult process.
EDITED TO ADD: Pictures
Please note: These pictures are do not represent defective or misaligned product, they are just meant to be helpful illustrations of the specific parts of the rifle.
The front sights are mounted working off aligning the index pin that is installed into the barrel extension. This index pin will represent the Top Dead Center (TDC). The center threaded bore of the front sight base (where the front sight post is installed), is lined up with the index pin to properly install the front sight base. Provided the bore is perfectly straight and the threads for the barrel extension are perfectly square, you will have a perfectly lined up barrel assembly.
Here is where it can get messy:
Looking at a upper receiver, if the index slot for the index pin is not machined perfectly on the center to hold the index pin at center, your front sight will be canted to one side.
For a flat top upper receiver, if the 1913-Pic rails that will hold your iron sight (at the position your iron sight is mounted) are not lined up parallel to a perfectly aligned index slot your front and rear sight alignment can appear canted.
Because rail mounted iron sights actually index off the right side of the flat top 1913-Pic rail, if that side of the rail is machined to thick or thin or the geometry is off, that will result in misalignment of the sights.
If the hole drilled to hold the rear sight aperture assembly (on a A2 or various BUISs) is not drilled on perfect center, that will result in misalignment of the sights.
If the hole in the rear sight aperture itself is not machined on perfect center, that will result in misalignment of sights.
So there are really a lot of variables to look at. Some will affect the sights more than others and some are easier to identify and isolate.