A flash flood swept through villages in a mountainous area of northern Afghanistan on Friday, killing at least 27 people, authorities said.