How fastener lengths are measured can seem a bit arbitrary until you imagine the screw being installed. Countersunk screws are measured as an ‘overall length’ figure as their full length will be recessed. Most bolts and screws are measured as the length under the head, as the exposed head is not factored into length measurements. The odd ball here is the oval head, as it acts as a semi countersunk screw. In this situation, we still assume the head height when installed is not counted into the length figure.
Fastener diameter sizing is generally straightforward. The thread diameter, or major diameter is the figure used in sizing, not the head diameter. The thread diameter for a screw (OD or Outside Diameter) will also be the same size used for nuts and washers (ID or Inside Diameter). So a M6 screw will take a M6 nut and washer (or in US sizing, a 1/4” screw takes a 1/4” nut and washer).
Especially when dealing with US sizing, it is incredibly important to use the thread count / pitch along with the diameter for sizing (ie, 1/4”-20 vs 1/4”-28 for coarse vs. fine thread). Thread pitch is fundamentally different from US to metric sizing and therefore absolutely not interchangeable. US uses a TPI, or Threads Per Inch for their measurements. So the above 1/4”-20 coarse screw, you could measure 20 threads in one inch to tell if it was 1/4-20 vs 1/4-28. Metric uses a ‘Thread Pitch’ measurement. In this case, it is the millimeter between threads, so a M6-1.0 would be 1 mm. between threads.