"How many kilometers did you walk?"
キロ is used as a counter, just like つ or にん（人）or ひき（匹）. Counters act directly on verbs and do not need a particle like を.
I answered kiro on a question that ask for kilometer, and this one doesn't have meter, only kiro. Reported.
I believe you can use を, but because キロ acts as a counter here, it's common practice to avoid putting particles between a counter and the verb.
If I had to ask someone about how many kilograms something weights what word should I use? Should I also use キロ?
Yes, I think キロ is commonly used for both kg and km, though if it isn't already super obvious by the context, you can also say キログラム or キロメートル respectively.
I'm afraid I don't know how to explain why, but I think you would have to say 「いくつのキロ歩きましたか？」 or 「キロを/はいくつ歩きましたか？」, both of which sound strange to me (not a native Japanese speaker).