It's nothing to do with using div vs h2 elements. It's because your div is using fixed positioning. % values for a position: fixed element are calculated as a % of the viewport (e.g. normally the browser width, but in your js fiddle the frame).
Your H1 tag is static position, so a percentage width based on the width of it's container, in this case the body. You might think that the body will be the same width as the viewport, but most browsers add some padding/margin to the body.
If you select the 'normalize css' option in jsfiddle, this probably gives the result you were expecting.