The same way you get anyone to stop hitting on you – clearly, concisely, and politely indicating that you are not comfortable with their advances, and that if they do not stop, it will affect your pre-existing friend/acquaintanceship.
I would say that there are layers to this question that go a bit deeper into the psychology of why people in relationships flirt with people outside it, but aside from handling the situation with respect and discretion, it's best to minimize your involvement as much as possible if you aren't interested in pursuing an affair.
How do you get a girl who's in a relationship to stop hitting on you?