Why are there cockroaches in a clean riad?

The short answer

Climate and infrastructure, not hygiene.

Buildings in the medina share walls and drainage channels — entire city blocks are connected underground. A cockroach in a spotless riad didn't originate there. The species that thrives here (Periplaneta americana) can flatten through a 3mm gap and breeds in temperatures Marrakech maintains for seven months of the year.