It is probably because she was already sleeping with Jaime even before she was about to marry Robert. In the book, she killed her firstborn and her reasons for doing this is because of her spite and somehow, because of her love for Jaime. She believed that by having Jaime’s children, she could show her father that the love that she has with Jaime is worth fighting for.
At the same time, she can have children that she loves and she will also have Jaime by her side. She may have been forced to marry Robert, but because Robert was also abusive, she ended up hating him even more. This ultimately made her kill Robert.