The reason is that 7-dehydrocholesterol is photolyzed by UV light in the 280-320nm range (mostly UVB) to previtamin D. Sunblock works to absorb UVB (and usually UVA) to prevent it from penetrating your skin. Thus sunblock limits the amount of UVB penetrating your skin, and limits your ability to make vitamin D.
That being said, yes, you will still make some vitamin D with sunblock on because sunblock is not perfect at absorbing UVB. Just not as much as you would without.