Shotguns are excelent for urban combat (huge stopping power + not having to worry about a stray bullet penetrating walls and killing random people, which is kind of a problem with most rifles) or any other situation in which close quarters shootouts is going to happen, though, which is why shotguns are a popular law enforment and home defense weapon.
Sure, if you're going to conflicts on open fields or any sort of medium-long range engagement, like military operations in non urban environments, then you might as well ignore them, since trench warfare is pretty much dead. However, when trench warfare was a thing, shotguns really did make a big ass difference. Its one of the main reasons as to why american troops usualy did better in trench combat than most ww2ww1 armies, since the US army was pretty much the only one to use shotguns at the time, and trench combat in ww2 essentialy meant one of 3 things, if you didn't have a submachinegun at hand: 1-awkwardly using your rifle at close range; 2-go full on CQC with your bayonet or knife; and 3-pulling out your pistol and hoping you hit them in a vital area before they hit yours.
They're also great against unarmored targets, which is, again, why they're a great law enforcement weapon (also why they're popular with prison guards that dont sit in towers all day).