This is discussed at some considerable length in this article from howstuffworks. In short, his swiping is to be viewed less as a character flaw and more of a character trait:
Show co-creator Valerie Walsh gives us some further insight:
Swiper is a one-dimensional character. You don’t know why he steals,
and we did that on purpose. Kids this age are learning about more
complex thinking. The emotional and psychological reasons behind
someone being bad have to be explained so thoroughly that we didn’t
want the back-story…. We’ve had this discussion with advisors who
wanted us to get into the motivation behind Swiper’s bad behavior. We
decided that it’s cleaner without it. Similar to villains in fairy
tales, we don’t get into the why.
By extension, his motivation for not swiping after being confronted by Dora ("no swiping!") is also intentionally unexplained.
Out of universe, the show's other co-creator Chris Gifford has described the phrase as a simple strategy to empower children in dealing with the threat posed by Swiper:
And what about Swiper, the villain?
That was pretty controversial actually at the time. There were a lot
of people who asked us not to put Swiper into the show. As a matter of
fact, because they kept going through how to reduce or adjust Swiper’s
teeth, “Round them out!”
And I just wanted him to have sharp teeth because the more threatening
Swiper was; the more powerful kids felt and be able to stop him. So
now they have the strategy to keep saying, “Swiper no swiping”, and
then Swiper stops. And that I think, is a big part of the Dora success
because you know he is a threat.