Psilocybe spores come from magic mushrooms that grow the wild. However, the substance they contain – psilocybin– remains controlled, which makes these mushrooms illegal to sell, buy and consume. However, psilocybin spores reside in a rather legal gray area, because they do not contain psilocybin yet (the substance appears in later stages of development). As such, spores can be used for scientific studies on magic mushrooms, so they can be bought/ sold safely, as long as you use them for the right purposes (identification and research).
You can easily find online websites or platform where you can buy Psilocybe shroom spores; a Google search is enough to reveal lots and lots of results, ranging from Facebook and other social media groups to online shops.
Spores can be purchased in two primary forms: prints and syringes. You can use them both in an active substrate, to grow the mushrooms you want to experiment on. However, you should purchase your spores from reliable sources, because they can easily get contaminated if some important requirements are not respected. Besides, if you do not check your sources, you risk becoming the victim of fraudulent advertising, and there may be no way to get your money back.
Finally, yet importantly, do not forget to check your local laws before purchasing them.