To me, the prison scene makes perfect sense.
First off, if you're a woman (or a man) whose soul is torn between desire and taboo - or Id and Super-Ego if you want to go full Freud on it - it is often easier to lift a bit of your barriers with a stranger, completely unrelated, than with someone who knows you, is in a close relationship and can judge you.
Second, she felt safer than in other situation. She was in a jail, surrounded by guards, with a man who would never be able to cross boundaries. She could let herself go knowing that she would never be forced to go beyond what she feels right.
Third, she could justify the flirting to herself because she was, at the same time, a filthy whore and a devote, good wife. She was doing it for her husband, after all, therefore in the situation there was no dilemma between giving in to desire and being a loving, caring partner. Quite the opposite, the sluttier she behave, the more she was demonstrating her love for Liam (which, after all, is also the mechanism underneath a good hotwife experience).
Of course I appreciate some might disagree, just my two cents.