Are the 21 countries expelling Russian diplomats only to show solidarity with the UK or are there any other reasons involved?
Likely yes. You can just compare counts of diplomats expelled, by countries:
- US: 60
- GB: 23
- Ukraine: 13
- France,Germany, Poland, Canada: 4
- about 15 countries 3,2,1 diplomate.
Some countries as Austria rejected expelling, motivationg it with lack of proofs in GB charge to Russia.
And another side of "This is a strong action we do". Russia will answer symmetrically, and impact western spy networks too, so result is more than disputable.
For now, Russia answered symetrically - it is diplomatic practice to answer in equal numbers.
There are other benefits that countries can get from expelling Russian Diplomats. Diplomats are involved in spying. There is no great secret about this. Countries can use this situation to disrupt Russian spy networks.
Given that they also believe that Russia was responsible for using a nerve toxin in a foreign country, they can hope to discourage Russia from carrying out similar attacks in other countries.
They can also give the message to other states that hostile acts in their territories will be responded to. The expulsion of diplomats is a public symbol that "action is being taken".
As these are coordinated actions, the hope must be that the various countries that are expelling diplomats can get the benefits of disrupting spy networks and so on, without as much of the negative consequences.