In short, a 2x4 was originally 2x4 inches, full stop, but it was found that this size wasn't necessary for the strength being applied to them in construction. We were wasting lumber for no reason. They went through a few cycles of sizing down as the actual needed strength was understood better. The naming convention stuck, though.