They both can do it and no doubt others can too.
To the OP,
Short barrel/short frame handguns though are largely purposed for ease of concealment and pocketability.
With a shorter barrel length thus sight radius decreases resulting in increased effort to aim with accuracy and by that increased variance in accuracy.
Short barrel/compact guns are not inherently inaccurate. It's just that it's more difficult for an individual shooter to be more accurate with them as opposed to that of having a longer sight radius.
Exact same is the case with all matter of shotguns regardless of barrel length and rifles as well.
It's basic physics.