How can I prevent KM from adding a space to my Pastes?

I frequently copy and paste variable names when I'm editing macros. Sometimes I paste and KM inserts a space after the name, sometimes it inserts a space before the name, and sometimes it inserts no space at all.

How can I prevent KM from ever inserting a space when I paste?

You can't.

It is a known issue, and @peternlewis has graciously agreed to change most, if not all, of the KM Actions that are affected to NOT use smart copy/paste (a macOS feature which causes the problem).

Look for it in the next version of KM.