Solution: Some scholars believe that the priesthood was extended to include David’s sons, granting them a kind of honorary priesthood. However, since there is no indication of this in the text, it does not seem likely.
Probably a broader understanding of the word for priest is employed here. The Hebrew word for “priest” (kohen) is also used for servant, minister, or counselor. David’s sons did not offer sacrifices (only Aaron’s sons did), but they were domestic priests or spiritual advisors.