the 17mm thin nut (locknut) does protrude beyond the cassette. Otherwise you'd be bolting the cassette right onto the dropout.
The distance from the outside of the locknut on one side of the wheel, to the outside of locknut on the other side (or OLD, over locknut dimension) is generally equal to the distance between the inside of the dropouts. Those nuts are flush against the drops when the wheel is mounted.
On the outside, where the nut tightens the wheel onto the bike, there is sometimes a flanged nut, which is sort of like a nut with a built in washer, and there is sometimes a nut with a ridged or serrated washer beneath it. These go on the outside of the dropouts, not wheel side.