"How many pineapples do they have?"
Translation:Kiom da ananasoj ili havas?
Because it's the complement of the preposition "da", and prepositions (in general) don't take the accusative case after them.
And no, you couldn't say "da ananasojn" in any situation (but "Kiom da ananasoj havas li" would be fine, and could only mean "How many pineapples does he have" -- "How many pineapples have him" would be "Kiom da ananasoj havas lin").
Also note that while some people treat "kiom da" as a unit, it's not -- it's "kiom" + "da", and since the latter is a preposition, it has to stand in front of something.
For example, if someone is standing at your market stall, admiring your pineapples, you can't ask, "Kiom da vi volas?" for "how many do you want?" -- it either has to be "Kiom vi volas?" or "Kiom da ananasoj vi volas?".