Can a continuous effect that gives haste wear off?
The Artifact Creature would lose haste if the Engineer was destroyed because it is a continuous effect from a static ability whose source has disappeared. As you mentioned, this means the creature will be unable to attack this turn.

The one difference in your two scenarios is that in the second one, if the Artifact Creature had an activated ability with the tap or untap symbol in its cost, it could use that ability in response to the Lightning Strike being cast against the Engineer.