Most accurate way to measure lumber is using dial or digital calipers. Don't forget, if you used a roll-up tape measure, the little 'thingy' sliding on the end has to be used correctly to get the right measurement. Measure in multiple locations along the length to get an average. Also, check for 'wedging' of the lumber (think of the lumbar being cut in a wedge). If you are in a cold/dry climate it's going to shrink; vice versa if here in FL and high humidity.
And, it could have been milled outside the US or bad QC at the mill. Does not suprise me at all coming from a big box store

. HD seems to have the worst QC'd soft lumber. Loew's IMHO is better but not as good as a local trade supplier.