All those states have very specific historical reasons why they dodged unification with their surrounding countries. The most surreal being Monaco's sovereignty saved by Grace Kelly's fame as an actress moving American public opinion to pressure France not to swallow it.
Also, note, that all the towns you listed are (historically) worthless border towns wedged between titans who would violently oppose their neighbor swallowing them. Sure, now those microstates are rich, but historically they were worthless and not worth war with a powerful neighbor to take over.