The tricky thing here is that "combien de jours" is not the direct object of marcher (marcher is an intransitive verb which cannot have a direct object), therefore the past participle doesn't agree with it.
But don't worry, native speakers themselves get confused by all these tricky grammar rules.
"Have walked" is called Present Perfect. It generally refers to a completed action in the past. "Had walked" is Pluperfect. It refers to a previous action in the past, i.e., one which occurred before another more recent past action. It works like this:
- Combien de jours ont-ils marché ? = How many days did they walk? (or) How many days have they walked?
- Combien de jours avaient-ils marché ? = How many days had they walked?