I imagine there are a number of reasons. In some instances they were unaware the guy was married prior to becoming "emotionally invested" in him. Later they become empathetic about his "unhappy" situation. This leads to a sort of romantic escapism of "forbidden love".
In other instances such as in the workplace or when it is publically known that a man is married there are usually a couple of factors.
If the man is considered a "real catch" some of these women may believe they have a chance of getting him to leave his present wife and marry them. Rarely does this happen but there have been some very well public examples. Donald Trump left his then wife and married Marla Maples, Eddie Cibrian and LeAnn Rimes started off as lovers who were both married and they left their spouses to marry, Danny Moder (camera man) left his wife for actress Julia Roberts, and many years ago singer Eddie Fisher left Debbie Reynolds for Elizabeth Taylor. It's been reported that Marilyn Monroe actually (believed) JFK would leave Jackie Kennedy fro her. Monica Lewinsky thought she'd have Bill Clinton after he completed his second term.
However I suspect many women who get with married men (initially) see it as something temporary. The man usually spoils them with gifts, cash, outings, and very rich men have been known provide rent for apartments, cars, and pay for exotic vacations. If a woman is a "gold digger" or simply an "opportunist" dating a rich married man may seem appealing because she still will have time to herself to live a single's life with her single girlfriends while he's working or fulfilling his family obligations. The trap however shuts if she does fall in love with him and he tells her he has no plans to ever leave his wife or if one day he pulls the rug out from under her and stops providing for her financial needs.
Last but not least there are some women who enjoy being "the other woman" so much that if the man were to leave his wife the mistress would dump him! I personally know of such a case and have heard about others where the man "surprised his mistress" with the news he's leaving his wife only to find out the mistress was not in love with him and never wanted a full-time relationship.