Allah says;
لقد أخذنا ميثاق بني إسراييل وأرسلنا إليهم رسﻼ
Verily, We took the covenant of the Children of Israel and sent Messengers to them.
Allah reminds that He took the covenant and pledges from the Children of Israel to hear and obey Him and His Messenger. They broke these pledges and covenants and followed their lusts and desires instead of the law, and whichever part of the law they agreed with, they took it. Otherwise, they abandoned it, if it did not conform to their desires.
This is why Allah said,
كلما جاءهم رسول بما ﻻ تهوى أنفسهم فريقا كذبوا وفريقا يقتلون