Make the motion keys ‘n’ and ‘p’ take into account all messages, not just the open ones. The new motion keys correspond to the original motion keys ‘N’ and ‘P’.
(with-eval-after-load 'notmuch (let ((map notmuch-show-mode-map)) (keymap-set map "n" #'notmuch-show-next-message) (keymap-set map "p" #'notmuch-show-previous-message)))