There's multiple reasons and it differs from person to person.
For me, when I cheated on some of my exes, it was always due to some underlying issue with myself and the relationship I was in. Part of it was that I felt like my current guy didn't care about me. He was always making comments about how hot other women were, spending more time with his friends than me, not having sex with me when I wanted it but always expecting me to have sex when he wanted it, constant arguing in the relationship, etc. I wasn't happy. But I was also afraid to end the relationships for fear of being alone. To fulfill my selfish needs, to fill that hole that I felt like my guys didn't care about me, I strayed for someone else that did show that they cared about me. Two of the people that I cheated with were, like mentioned in a previous post, already a relationship in the making behind my guys' backs. After the first couple times I cheated, I eventually learned that I need to trust my gut, go with my instincts. If something seems bad, if I have any doubts that the relationship isn't working and we can't fix things, then I need to just end it. Cheating isn't fair to your SO, no matter how bad things are.
In some circumstances, it's about self control. Maybe your relationship is perfectly fine, but you still cheat because you can't resist temptation. Maybe you simply don't care enough about the other person to stay faithful.
Sometimes people cheat because they want a quick rendezvous and think they won't be found out. That it won't change anything. Perhaps sometimes their infidelity isn't discovered and they go on with their lives like nothing ever happened, but I think those situations are few and far between. Cheating almost always ends up badly.
And sometimes people have sex with multiple partners with no boundaries because they're in an open relationship, but that's something else entirely.
What it all comes down to is your own character, your own problems. There is always an underlying issue as to why a person is cheating on their partner. It could be about themselves or it could be about the relationship.