The loose or non-literal use of "miles" to mean "an unspecified large distance" is a semi-idiomatic usage that (presumably) dates back to a time before kilometres were very familiar to most English speakers. The usage has not caught up with metrication trends (same reason we write "tons of stuff" and not "tonnes of stuff"). "for" is optional in both cases.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
Cup cakeI have to say it sounds weird to say ...for kilometres.OK, well if so it may be that the "for miles" version is that much more idiomatic, and so less amenable to messing with.