The dimension is from the FINISHED wall, so if you are using 1/2" drywall, you'd want 12.5" from the studs. Some people go out a little further since you never know if they decide to put tile or wainscoating up and make the wall functionally thicker.
There is no standard on gap between the toilet and the wall...just that it will fit if you have 12". Some can run from nearly touching to over an inch. SOme of this is to account for manufacturing tolerances.