Well I guess deck guns were no good for what submarines had become... Generally WW2 subs can be seen as temporarily submersible weapons platforms. Deck guns were fine when the target didn't fire back, they were removed because they were becoming useless due to the increasing threat.
Besides, deck gunning is fun