Are effects from attacks mandatory or optional?
They are mandatory. With a simple comparison:

 

You can see that Alolan Sandslash's attack is mandatory, because it uses imperative tense, whereas Hitmonchan's first attack is not, because it uses "You may ..." phrase.

If you'd like a more reliable source, there is a list of official rulings named Pokémon TCG Rulings Compendium BW that contains many explanations how rules work with particular attack, card, or their combination. Here, you can find that there is a ruling for Bounce that we can use here:


  Q. Can I use Emolga's "Bounce" attack if I have no bench?
  
  A. Yes, you do as much of the attack as you can. First you do the damage, then you perform the switch if Emolga is able to go to the Bench. (Next Destinies FAQ; Feb 9, 2012 TPCi Rules Team)




This official ruling must be followed by all Pokémon that has the same attack (regardless its name), including your Alolan Sandslash. That means that you do the damage and then, unless you have no Pokémon on your Bench, you must switch it with with 1 of them.