I watched Avengers: Endgame. I couldn't understand what happened to Nebula when the Avengers time traveled. It was Nebula who revealed the Avengers' plan to retrieve the Infinity Stones to Thanos. What exactly happened?
Nebula from 2023 time traveled with the Avengers to 2014. While there, due to the fact that she has a partially cybernetic brain, her memories became accessible to the Nebula that was already there in 2014. Similar to how 2 computers on the same network can see each other's files.
Taking advantage of this, Thanos was able to find out about the Avengers' plans. He captured 2023-Nebula, and then sent 2014-Nebula to return to 2023 with the Avengers. In 2023, the 2014-Nebula set things up to allow Thanos, along with his entire army, including both 2023-Nebula and 2014-Gamora, to time travel to 2023.
The 2023-Nebula convinced 2014-Gamora to change sides; and together they escaped, and 2023-Nebula killed 2014-Nebula.
Nebula from 2023 travelled to the past with the Avengers and was captured by Thanos.
Under torture or due to the "network connection" the Avenger's plan is revealed and Nebula (2014 version) replaced her and travelled back to 2023 with the Avengers pretending to be Nebula 2023.
Nebula 2023 travelled with Thanos in his spaceship through time but escaped with Gamora's assistance in time to kill Nebula 2014.
Hence in 2023 there is only one remaining Nebula.
Of course, Nebula 2014 technically still exists because Captain America went back, replaced the Infinity Stones and reset her timeline so none of the above happened (as far as Nebula 2014 is aware).