I asked Mujahid regarding the prostration in Surat Sad. He said, "I asked Ibn 'Abbas, 'What evidence makes you prostrate?' He said, "Don't you recite:--'And among his progeny, David and Solomon..(6.84). Those are they whom Allah had guided. So follow their guidance.' (6.90) So David was the one of those prophets whom Prophet (Muhammad) was ordered to follow. David prostrated, so Allah's Apostle (Muhammad) performed this prostration too.'
• Sahih al-Bukhari, Vol. 6, Book of Prophetic Commentary on the Qur'an, Hadith 331
• Sahih al-Bukhari, Book of Prophetic Commentary on the Qur'an, Hadith 331