The word "he" refers to David. The reader should understand that David and Joab were probably in charge of other men who made the fortifications. (See: [[rc://en/ta/man/jit/figs-metonymy]])
This likely refers to a terraced structure that consisted of retaining walls with dirt filled in behind them. (See: [[rc://en/ta/man/jit/translate-unknown]])