Taken people are off limits.
When that happens you need to understand that people who are married or in relationships are offlimits. There are no extenuating circumstances to consider. It doesn't matter if s/he is also attracted to you. Taken people are offlimits.
Human decency requires us to avoid being home-wreckers. You also need to understand when you generally take your feelings to married people, you make them really uncomfortable.
Here are 4 things you should do when you are attracted to someone married.
1. Control your fantasies
If you keep fantasising about possibilities, your thoughts can turn toxic. Don't think about the life you could have with the person. If you find your thoughts wandering that way, occupy your mind. Play a video game, read a book, binge watch a series, volunteer with underprivileged people- just do something that would take all of your focus.
2. Manage your flirting
Don't call or text him/her. If they contact you, be as brief and straight to the point as possible.
When you find yourself alone with them, bring up the spouse in the conversation. Remind yourself that they are not for you.
Don't do the little touches, playing with your hair, flexing your arms, pursing your lips- don't do anything to attract attention to what you consider your best features.
Avoid spending time alone with them that could help foster any intimacy. Like going for drinks together.
3. Imagine them as horrible people
You're probably attracted to your married colleague because s/he's very nice and very attractive. You can use your imagination to manage your crush. Imagine them with a third eye or that they are an evil ruler in a Disney movie or a witch doctor in Afrocinema.
4. Treat the crush like a bad craving
Like cravings, crushes are temporary. If you're on a diet and you find yourself craving something unhealthy, you strive to remain strong and stick to your diet. If you are on a budget and you buy something you can barely afford you end up feeling horrible. Think of crushes the same way. Maintain enough self will to avoid those things that are bad for you until the craving passes.