Aligning tangents with AnimationCurve

When I add new key to AnimationCurve with a curve editor, it does not affect the curve line:

42910-key-added-from-editor.png

Tangents are nicely aligned with the curve. Adding new key doesn’t change curve’s shape.

But when I add the same key at exact same timestamp and value using script, the curve’s shape gets distorted. It’s because both tangents have different values:

42909-key-added-from-script.png

How can I align tangents with the curve the same way as curve editor does?

[EDIT] Script used to generate the second curve:

private void Reset() {
            curve = new AnimationCurve();

            var key0 = new Keyframe(0, 0, 0, 75);
            var key1 = new Keyframe(1, 1, 0.7f, 0);

            curve.AddKey(key0);
            curve.AddKey(key1);

            var valueAtTime = curve.Evaluate(0.142f);
            curve.AddKey(0.142f, valueAtTime);
}

I want too,seems need caculate the tangent at insert point