World is used in a restricted sense, like Jn 1:29 its limited to the elect, because this world has its sin taken away by the Lamb of God.
2 Cor 5:19 world is used in a restricted sense, because that world doesnt have sin charged/imputed to it
Which taketh away the sin of the world (ὁ αἰρων την ἁμαρτιαν του κοσμου [ho airōn tēn hamartian tou kosmou]). Note singular ἁμαρτιαν [hamartian] not plural ἁμαρτιας [hamartias] (1 John 3:5) where same verb αἰρω [airō], to bear away, is used. The future work of the Lamb of God here described in present tense as in 1 John 1:7 about the blood of Christ. He is the Lamb of God for the world, not just for Jews
A.T. Robertson, Word Pictures in the New Testament (Nashville, TN: Broadman Press, 1933), Jn 1:29.
Which taketh away. This denotes his bearing the sins of the world, or the sufferings which made an atonement for sin. Comp. Is. 53:4; 1 Jn. 3:5; 1 Pe. 2:24. He takes away sin by bearing in his own body the sufferings which God appointed to show his sense of the evil of sin, thus magnifying the law, and rendering it consistent for him to pardon. See Notes on Ro. 3:24, 25.
Of the world. Of all mankind, Jew and Gentile. His work was not to be confined to the Jew, but was also to benefit the Gentile; it was not confined to any one part of the world, but was designed to open the way of pardon to all men. He was the propitiation for the sins of the whole world, 1 Jn. 2:2
Albert Barnes, Notes on the New Testament: Luke & John (ed. Robert Frew; London: Blackie & Son, 1884–1885), 185–186.