I am aware that the phrase 「おかわり」 that is used when asking for second helping (of meals especially) is an idiomatic expression, so its usage is understood as it is. But, I'm curious about the origin of this phrase because it seems to be derived from 替わる / 代わる(P) / 換わる, which means "to be exchanged/switched". How did this phrase come into the usage? Is it the case that in the past when people asked for second helping, something was exchanged (bowl, chopsticks etc)?
It means 'replacement'. What is being replaced is the content, not the container. You can use a related expression
替え in a wide variety of replacements. Mostly in Kyusyu area, when you go to a noodle shop, you can ask for
替え玉, which is (a ball of) replacement noodle that fills in your empty bowl still with leftover soup.
替え芯 means a replacement lead for a mechanical pencil or replacement staples for a stapler.