Per the OP's comment above, this was "Behind Her Eyes" by Sarah Pinborough.
Louise is a single mom, a secretary, stuck in a modern-day rut. On a rare night out, she meets a man in a bar and sparks fly. Though he leaves after they kiss, she’s thrilled she finally connected with someone.
When Louise arrives at work on Monday, she meets her new boss, David. The man from the bar. The very married man from the bar…who says the kiss was a terrible mistake but who still can’t keep his eyes off Louise.
And then Louise bumps into Adele, who’s new to town and in need of a friend, but she also just happens to be married to David. David and Adele look like the picture-perfect husband and wife, but then why is David so controlling, and why is Adele so scared of him?
As Louise is drawn into David and Adele’s orbit, she uncovers more puzzling questions than answers. The only thing that is crystal clear is that something in this marriage is very, very wrong, but Louise can’t guess how wrong―and how far a person might go to protect their marriage’s secrets.
The Goodreads reviews frequently reference the ending (which basically matches your summary) with varying degrees of "this was brilliant" and "I feel cheated by the ending". You can find a spoiler review here.
Louise tries to help David flee from Rob-Adele's clutches. She also digs into Rob's history, calling Rob's sister who confirms Rob was never to be seen again, confirming Louise's suspicions that Rob is dead. But before any of this can really come to a head, Rob-Adele tricks Louise into coming to her home by pretending she is committing suicide. Rob-Adele then sets fire to her own beautiful townhouse. Louise comes to Rob-Adele's home only to realize she can't break in to help; she decides to try astral projecting inside to save Rob-Adele. Rob-Adele seizes this opportunity to switch bodies with Louise, becoming Rob-Louise. Rob-Louise then actually overdoses Adele's body so that Adele-Louise dies. Rob-Louise then pulls Adele's body from the burning home so that she looks like a hero who tried, but failed, to save her friend.