A United States service member walked out of a military base in a rural district of southern Afghanistan on Sunday and opened fire on three nearby houses, killing at least 16 civilians, including several children, local villagers and provincial officials said.