Although the popularized understanding of the Gemara in b.Shabbath 56a is that David haMelekh never actually sinned with Batsheva` but only appeared to sin, the Gemara as a whole, and the tradition as taught by the Rishonim are not so monolithic on this question. In fact, aside from the statements made to this effect by Rav Shemu'el Bar Nahmeni and Rebi Yehudhah haNasi in this passage of Masekheth Shabbath, all other references made to the incident of David and Uriyah haHiti reflect the opposite view, namely that David did indeed commit the sin of esheth ish, and that such an interpretation is the obvious peshuto shel miqra (plain meaning of the Biblical text).
The dissonance with the popularly taught view begins with a line in the very text of the Gemara in Shabbath 56 where Rav answers the objections to David sinning raised by both Rebi and Rav Shemu'el bar Nahmeni by saying, "Those who are descended from David seek to defend and expound his merits." In other words, he is noting that although the text of the Tana"kh clearly spells out the nature of David's sin, due to the public and embarrassing mistakes of their esteemed forebear, they seek to expound the text in a forced way to exonerate him.
Other places in the Gemara which hold the opinion that David haMelekh did sin are:
- b.Sanhedrin 107a (Batsheva is a fully-married woman with whom David sinned)
- b.Kethuboth 9a-b (no names are explicitly mentioned, however the mefarshim and Rishonim understand the discussion to be making reference to David and Batsheva)
- b.Avodah Zarah 4b-5a (David, through his admission of guilt, elevates the "yoke of teshuvah)
- Yoma 22b (David is punished four-fold for sinning with Batsheva)
Amongst the Rishonim are also opinions to the contrary:
- The Riva"n (Shu"T Hakhmei Provanssia 71) relates that although Haza"l tried to be limudh zekhuth on David, the fact that he blatantly sinned with regard to esheth ish is the undeniable peshuto shel miqra from which the text can never budge.
- The Rada"q also affirms the sinning of David and Batsheva.
- Rav Yisshaq Abarbanel writes similarly to the Riva"n regarding the clear communication of the Tana"kh that David did indeed sin.
So, as specifically regards your question(s): The answer is that is that by having intercourse with Batsheva, the wife of Uriya haHiti, when the conditional get given by those going out to war in order to prevent agunoth only takes effect after a husband does not return from battle or dies, he committed esheth ish. It is for this reason that he did teshuvah and why Nathan haNavi assured him that he would not die for his sin (2 Shemu'el 12:13).
Kol tuv.