As the god of mischief and lies, Loki is no stranger to pulling a fast one on his supposed allies.
At the end of the day, Loki is not a character bound by any sort of morality. He does what he needs to do at any given moment.
https://www.cbr.com/loki-sentry-sacrifice-kid-loki-body-steal/