I'm not really familiar with the bicycle production process, but in the case of motorhome manufacturing (Winnebago), two identical bare chassis come in the door on one end, and by the time they reach the exit door, one may be a $100,000 plain Jane, while the other chassis has been adorned such that the asking price has reached 175k or more. I suspect this happens with bikes as well. The manufacturing of the frames happens in the same area, on the same machine, with identical tolerances, and several are created from the same roll of raw material.
One thing with bikes is to note what a sub model is made from compared to a higher cost sub model. By sub model, I refer to the differing tags added on to the same models name. Words like Expert, Pro, Elite, etc, such as Specialized Rockhopper Expert vs the Specialized Rockhopper Sport. Obviously there are carbon fiber and alloy versions. But even say with carbon, there may be 2 differing materials or lay up techniques used. For instance, Stumpjumper FSR Carbon Elite with a FACT9 carbon frame vs. An S-works FSR carbon Elite having a frame of FACT11 carbon (same model year). That would infer two different levels of quality perhaps.
The same goes for aluminum. You may note the same model name but one sub model is "A1 aluminum" while the other sub model is made from M4 aluminum. They share the same geometry but use different alloys or produce using two different methods of production. So watching the material specs between sub models as well as any geometry differences (I'm talking more the seat tube and head tube angles of the same size bike rather than comparing head tube length between two different sizes which will differ at some point in the size range) is what I do to determine if there are large differences in overall quality.
Thus if you find two of the same size and model bikes but with different sub model names and a large discrepancy in price, and these bikes share both the same material and the same geometry, I feel that they both started life coming off the same production machine as equals yet ended up at two price points with differing sub model names due to the spec'd components as opposed to differing quality levels of the base frame.