And they used to hew out dwellings from the mountains, (feeling) secure.
meaning, they were without fear and they had no real need for those houses; it was merely a form of extravagance and work without a purpose. This could be seen from their work in the houses in the Al-Hijr through which the Messenger of Allah passed on his way to Tabuk. He covered his head and urged his camel to go faster, saying to his Companions:
لاَا تَدْخُلُوا بُيُوتَ الْقَوْمِ الْمُعَذَّبِينَ إِلاَّ أَنْ تَكُونُوا بَاكِينَ فَإِنَّ لَمْ تَبْكُوا فَتَبَاكُوا خَشْيَةَ أَنْ يُصِيبَكُمْ مَا أَصَابَهُم
Do not enter the dwellings of those who were punished unless you are weeping, and if you do not weep then make yourself weep out of fear that perhaps what struck them may also strike you.
فَأَخَذَتْهُمُ الصَّيْحَةُ مُصْبِحِينَ