Yes.
> But if, in the minds of those people, just before I hit the switch, a collective identity forms -- "The People of the Gas Chamber" -- then my act is instead genocide, due to their internal mental state?
No, acts directed at the extermination of a people, not that incidentally cause it, are genocide. You’d still be committing mass-murder-but-not-genocide, not that the distinction is likely to be more than technically significant, unless you are a acting in a context so as to not render mass murder an international crime but only one subject to local jurisdiction. (Genocide is universally subject to universal jurisdiction, while mass murder requires special additional circumstances to rise to an international crime — either a war crime or crime against humanity.)
And when mass killing does rise to genocide, its not “instead of” being mass murder, but “in addition to”. Same with deportation, imprisonment, torture, rape, enslavement and other “act based” crimes against humanity when done as part of a mechanism aimed at destroying a people. The offenses are cumulative, not alternative.
And the goal, to the actor, is not so much killing, as it is the destruction of the belief in each victim's mind, that they belong to the group. The destruction of the body and mind holding the belief is just a means to this end.
This is all very strange.
It supposedly protects distinct cultural groups from being destroyed which is the right thing to do in today's definition. However, as Sapiens put forward, empires throughout the history have assimilated all sorts of people, and objectively speaking, they didn't necessarily made the lives of those people worse, and in many cases voluntary bi-directional cultural influence took place, until one is barely distinguishable from another. Therefore, I agree to some extent that it seems weird to elevate this definition of "genocide", even sometimes cultural, as something graver than the act of actual mass murder. Sometimes they do happen together, to some extent even in this example, where the children died en masse. But in many occasions throughout the history, the gradual disappearance of a cultural identity is a very distinct thing than people actually dying or having their living conditions worsening. As you said, group identities disappear and reappear in an endless ebb and flow, maybe not so much in the modern world with all these nation borders, but much more commonly throughout the history.