And [recall] when Moses said to his people, "O my people, indeed you have wronged yourselves by your taking of the calf [for worship]. So repent to your Creator and kill yourselves [i.e., the guilty among you]. That is best for [all of] you in the sight of your Creator." Then He accepted your repentance; indeed, He is the Accepting of Repentance, the Merciful.
Also, remember that Allah’s allowing you to ask His forgiveness for worshipping the calf, when Moses (peace be upon him) told you that you had wronged yourselves by taking the calf as a god and worshipping it, were from the blessings of Allah. Moses told you to ask for forgiveness and repent to your Creator by some of you killing others, because turning to Him in this way was better for you than persisting in disbelief, which would lead to an eternity in the fire of Hell. So, you did this with Allah’s approval, and He forgave you, for He is Forgiving and Merciful with His servants.