Thank you. You are beginning to touch on the question. I do consider that the Biblical passage in John 20 (often used as an evidence for confession) is more of a higher level teaching of Jesus that relates the the Church’s authority to bind and loose. In fact, I read somewhere that Catholic Scripture scholars today don’t directly relate John 20:21-23 to the practice of confession (correctly me if this is not true). Of course John 20:21-23 is certainly undisputable evidence of the authority given to the Church. In the context though it seems relate to the birth of the Church and as such seems to relate to powers of the Church to proclaim the Gospel and “judge” whether hearers are in proper disposition to be acceptable members of the Church (e.g. true faith, right understanding, reverent attitude toward Jesus and His Church, i.e. shake the dust off your feet, whose sins you retain). This is why I consider it as somewhat more high level than directly related to the current practice of confession which apparently developed over centuries.
There is also clear biblical support for confession in general and at the beginning of mass we confess our sins to one another which seems to be the mapping of our practice to the Bible passage regarding confessing ones sins to one another (as opposed to the sacrament, or perhaps in addition to it?)
Jesus’ own authority to forgive is granted to the Church. In the Bible when He forgives, there seems to be little formal confession, e.g. the woman in adultery, the paralytic, the woman at His feet. None of these are seen confessing per se.
Haydock Commentary, John 20:23
23 *Whose sins you shall forgive, they are forgiven them: and whose you shall retain, they are retained.
Ver. 23. Whose sins you shall forgive,[2] &c. These words clearly express the power of forgiving sins, which, as God, he gave to his apostles, and to their successors, bishops and priests, to forgive sins in his name, as his ministers, and instruments, even though they are sinners themselves. For in this, they act not by their own power, nor in their own name, but in the name of God, who as the principal cause, always remitteth sins. This is generally allowed to be done by God’s ministers in the sacrament of baptism, as to the remission of original sin; and the Catholic Church has always held the same of God’s ministers, in the sacrament of penance. (See the Protestant Common Prayer Book, in the Visitation of the Sick.)
— Whose sins you shall retain, they are retained: by which we see, that to priests is given a power to be exercised, not only by forgiving, but also by retaining; not only by absolving and loosing, but also by binding, by refusing, or deferring absolution, according to the dispositions that are found in sinners, when they accuse themselves of their sins. From hence must needs follow an obligation on the sinner’s part, to declare, and confess their sins in particular, to the ministers of God, who are appointed the spiritual judges, and physicians of their souls. A judge must know the cause, and a physician the distemper: the one to pronounce a just sentence, the other to prescribe suitable remedies. (Witham)
— See here the commission, stamped by the broad seal of heaven, by virtue of which, the pastors of Christ’s Church absolve repenting sinners upon their confession. (Challoner)
[2] Ver. 23. Whose sins you shall forgive, &c. See St. Cyril, lib. xii. in Joan. p. 1101, metanoousi sugginoskontes. St. Chrysostom, hom. lxxxvi. p. 517. nov. Ed., Magna est sacerdotum dignitas, quorum remiseritis peccata, &c. See also lib. iii. de sacerd. t. 1. p. 383. nov. Ed. Ibid., noli esse incredulus, sed fidelis, kai me ginou apistos, alla pistos.
haydock1859.tripod.com/id113.html