Awwam reported,

Someone said, "I asked Mujahid about the sajdah in Surah Sad."Mujahid said, "I asked Ibn Abbas, 'Where did you derive this prostration from?'Ibn Abbas replied, "Do you not read 'And of his descendants were Dawud and Sulayman' [Anam 6:84], and 'Those are the ones whom Allah has guided, so follow their guidance' [Anam 6:90]? Dawud was among those whom your Prophet ﷺ was commanded to follow. Dawud عليه السلام performed that prostration, so the Messenger of Allah ﷺ performed it as well."

Azami 8451

Sahih

عن العوام قال

سألت مجاهدا عن سجدة في ص فقال: سألت ابن عباس من أين سجدت؟ فقال: أو ما تقرأ {ومن ذريته داوود وسليمان} {أوليك الذين هدى الله فبهداهم اقتدة} فكان داود ممن أمر نبيكم ﷺ أن يقتدي به، فسجدها داود عليه السلام فسجدها رسول الله ﷺ.

الأعظمي 8451صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Stories of the prophets
Chapter
Reports of Dawud عليه السلام
Section
Prophet ﷺ following the example of Dawud عليه السلام
Numbering
Jami al-Kamil 8451 (2nd edition)
Azami 8451