Although the popularized understanding of the Gemara in b.Shabbath 56a is that Dawidh haMelekh never actually sinned with Bathsheva` 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 Dawidh and Uriyah haHiti reflect the opposite view, namely that Dawidh 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 Dawidh sinning raised by both Rebi and Rav Shemu'el bar Nahmeni by saying, "Those who are descended from Dawidh 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 Dawidh'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 Dawidh haMelekh did sin are:
- b.Sanhedrin 107a (Bathsheva is a fully-married woman with whom Dawidh sinned)
- b.Kethuboth 9a-b (no names are explicitly mentioned, however the mefarshim and Rishonim understand the discussion to be making reference to Dawidh and Bathsheva)
- b.Avodah Zarah 4b-5a (Dawidh, through his admission of guilt, elevates the "yoke of teshuvah)
- Yoma 22b (Dawidh is punished four-fold for sinning with Bathsheva)
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 Dawidh, 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 Dawidh and Bathsheva.
- Rav Yisshaq Abarbanel writes similarly to the Riva"n regarding the clear communication of the Tana"kh that Dawidh did indeed sin.
So, as specifically regards your question(s): The answer is that is that by having intercourse with Bathsheva, 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).