How could someone do what (the Church says) is wrong and not be living in sin?
According to Catholic teaching, wrong and sin are not the same thing. Wrong is harm, disorder, destruction; it is in the objective or external world. Sin is self-distancing from God; it is in the heart. Sin is more a general attitude than any particular action. We sin when we deliberately do what we believe is wrong. Then in our hearts we opt for evil. Then we move away from goodness and from God, who is good.
It may well be that what you do is not wrong at all. But if you think it is and you do it anyway, well, you are corrupt. That’s sin! Or what you do may really be wrong. But if you don’t honestly think so and you do it, well, your heart is not really amiss. You may be uninformed, naive, or stupid, and even dangerous, but unless you neglected to inform yourself, you are not sinful.
The Church teaches right and wrong but never says who is a sinner. Only God knows our hearts. Many homosexual people simply cannot believe that gay sex is wrong. So they do what for them is “the best they can do,” though Church teaching says that homogenital acts are wrong. Still, according to the same Church’s teaching on conscience, they do not sin in their hearts or before God. Then they need not confess what is not sin, and they may participate in the Sacraments of the Church.