It appears that the confusion both in your question and in the question linked stem from a confusion of reference frames, leading to an apparent difference in outcomes across multiple tests of the "same" process. The original question regards a cannon that fires a 2kg shell at 1km/s muzzle velocity, i.e. imparts 1MJ energy to the projectile. The question then points out that the same cannon mounted on an airplane flying at 1km/s will result in the projectile having a velocity of 2km/s when fired, and thus a kinetic energy of 4MJ (since energy scales with the square of velocity).
Note that the above velocities are both in relation to the ground. Obviously if you consider from the frame of reference of the cannon, the projectile has the same muzzle velocity in each case - since the same amount of the same propellant is used and thus the same chemical energy is released - and thus there's no difference between being on the ground or mounted to a plane. In the frame of reference of the projectile, it gains no kinetic energy whatsoever and instead the rest of the universe accelerates past it with an enormous collective kinetic energy difference. Of course this violates conservation of momentum because we are ignoring the acceleration of the reference frame itself.
That said, the logical reference frame to use for these calculations is the center of mass of each system - of the Earth-projectile system for a cannon fixed on the ground, and the plane-projectile system for a cannon fixed into an airplane. In each case, when the propellant is ignited, an equal momentum is transferred to each "side" of the system, and the total absolute momentum is a function of the released chemical energy of the propellant.