How did the early Christians come to believe that gentiles did not need to be circumcised?

For us today it seems obvious but in those times they believed that the Law was given by God and it was a clear requirement of the law. We still believe that.

Circumcision, along with food laws and Sabbath, were special kind of markers that marked out who God’s people were. Circumcision is talked of as a sign of the covenant.

Early on, for example with Cornelius, the Holy Spirit came to dwell in him and his household after they heard the message, believed and were baptised.

Now if God’s Spirit dwells in someone how can it be said that they are not part of God’s family. They must be.
If they are part of God’s family without circumcision, there is no need for them to be circumcised. The Spirit is already a marker of their position. To have them circumcised as well implies that circumcision is a more important marker than the Spirit of God. To say that is actually approaching the blasphemous.

This makes sense as God’s long term plan was to bring the nations to follow him. Abraham, and then his family, is often seen as God’s plan B after Adam failed.

What does that mean about the law. Jesus as the Messiah, the King, represents his people. What is true of him is true of his people. When David fought Goliath he represented Israel.
His victory meant a victory for Israel.
Now when Jesus died and rose again in a sense his people have died and risen again and they now dwell in a new age.

If Jesus death is linked to the exodus. Then the appropriate accompanying law must be linked to Pentecost and the giving of the Spirit. Thus the guidance for this new age is the Holy Spirit and also what the apostles, teachers and prophets wrote early on, guided by the Holy Spirit.