It still doesn't make sense. He stuck with Luffy that whole time, he's already a wanted pirate. even more so for breaking out of Impel Down, killing Ace would have done nothing to benefit him at that point.
He didn't stuck with Luffy at all, he tried to run with buggy several times, first he got punched into the hole, the second time the ramen lion crushed the ground and I believe the third time the minotaur broke the floor.
He was nowhere to be found in the Okama level, his only option was to get on Luffy's ship or get killed by Magellan.
Killing Ace would not blow his cover and take away the pirates objective of the war, and the whole thing would be over pretty soon. Mr. 3 has no connection to Ace or Luffy, neither did he owe Luffy anything. He is a pirate, he can do what he wants