Russia signed a pact guaranteeing Ukrainian sovereignty in exchange for their portion of the Soviet nuclear stockpile [my misremembering, this was incorrect: and a large amount of money]. You can see how much signatures are worth with Putin.
This wasn't "messing around". For sure, that Russian unit was sent to capture the reactor. Wanting to control infrastructure like generators is an obvious and (fairly) rational strategic goal. Presumably the commander that ordered it felt it was worth the risk. That may not be a correct analysis (we'll see, I guess), but it surely wasn't done on a whim.
It's quite naive I know but if you make the consequences very clear and extremely bad for the troops, it might really deter them.
Or Russia is implementing a something similar to a scorch= the-earth policy.