This is a portion of what the Insight book says about the affair between Judah and Tamar:
Therefore, subsequent to Judah’s becoming a widower, Tamar, on learning that her father-in-law was going to Timnah, disguised herself as a prostitute and then seated herself at the entrance of Enaim on the road Judah would be traversing. Not recognizing his daughter-in-law and assuming her to be a prostitute, Judah had relations with her. When it later came to light that Tamar was pregnant, Judah demanded that she be burned as a harlot. But upon the presentation of the evidence that he himself had made her pregnant, Judah exclaimed: “She is more righteous than I am, for the reason that I did not give her to Shelah my son.” Thus unwittingly Judah had taken the place of Shelah in fathering legal offspring. Some six months later Tamar gave birth to the twins Perez and Zerah. Judah had no further relations with her.—Ge 38:12-30. (Judah, it-2 pp. 123-128)
As we see, Judah wanted to burn Tamar as a harlot, but he was not concerned of himself when he had sex with Tamar as a harlot. Of course, Tamar was not a harlot, but Judah thought she was. This means that Judah (if existed) did it more than once. He thought it wasn't wrong to have sex with a prostitute, though a prostitute must be burned. Buuuuuut, Judah can't be disfellowshipped for that, no, no, no, he was a good man, because David,....,and Jesus would be his descendants. To have a better understanding of how Judah can be excused, we have to read the Watchtower:
Questions From Readers
What circumstances caused Judah to have sexual relations with a woman he thought was a harlot, as stated at Genesis 38:15, 16?
While Judah did have sexual relations with a woman he thought was a harlot, in reality she was not a harlot.......
Judah acted wrongly in that he did not give Tamar to his son Shelah as promised. He also had relations with a woman he thought was a temple prostitute. This was contrary to God’s purpose, which was for a man to have sexual relations only in the marriage arrangement. (Genesis 2:24) In reality, though, Judah did not have relations with a harlot. Rather, he unwittingly took the place of his son Shelah in performing brother-in-law marriage and thus fathered legal offspring. As for Tamar, her course was not an immoral one. Her twin sons were not considered to be the sons of fornication. (w04 1/15)
So, Judah just did something wrong against to God's purpose and then he wanted to burn Tamar, but don't worry, "In reality, Judah did not have relations with a harlot", in the same way that Rutherford just loved Berta and Bonnie and sent witnesses out "from door to door to face the enemy while he went from drink to drink".