( وَكَم) (And how many): The number is too large to be counted.
( مِّن قَرْيَةٍ أَهْلَكْنَاهَا فَجَاءَهَا بَأْسُنَا بَيَاتًا) (cities have We destroyed, and Our punishment came to them at night): The punishment befell first, then the city gets destroyed. This is because these are the words of Allah (swt) and not those of a human being; the decision of destruction was predestined from pre-eternity.
( بَيَاتًا أَوْ هُمْ قَائِلُونَ) (at night or while they were sleeping at noon): These are times of rest, either at night when they are asleep, or while napping at noon.