Sanctions are basically a way to do something and be seen as doing something, without actually having to do something even more distasteful or controversial.
It's like wearing a "down with those guys!" tee-shirt.
It's a compromise between doing something utterly stupid like going to war and between losing all political support by being seen as a supporter of the other regime. Ie, Reagan opposed the sanctions and which caused a lot of people to erroneously conclude that he must have supported apartheid.
The political arithmetic isn't too hard. Your choices boil down to being seen as supporting the existing regime, ssupporting the opposition to the regime (ie, arming them, giving them money, etc), or sanctions. Of course there are nuances in between those extremes.