There are several paths by which both US and Russian artifacts from the space program make their way into private ownership. These include deassession from the Government via authorized surplus sales, disposal of materials by the contractors who produce the technology at the conclusion of a program; retention of gifted or salvaged items by individuals and their family members who worked on or were affiliated in some way with the program and then subsequently release the artifacts for sale.
Keep in mind that in addition to flight vehicle components that actually flew on mission, multiple examples of each artifact were typically produced for developmental testing, spares ect.
Within the U.S., the National Air and Space Museum has first right of refusal to decline the transfer of government owned artifacts that NASA no longer has an interest in retaining, After that offers may be extended to other museums and institutions. Ultimately if no formal interest expressed, items can be sold via authorized property disposal channels (GSA auctions for example) to private citizens.
In addition, as a result of HR 4158, astronauts who crewed the early US Space missions (Projects Mercury, Gemini, Apollo and Skylab) and who were in possession of certain artifacts from those flights as of the law's enactment, were recognized as legal owners and authorized to subsequently determine those items disposition (to include selling them to other individuals).
I have obtained many artifacts through a varienty of paths to include flown and unflown materials from both the US and Russian programs. There is a robust collector market that is sustained by heavy global interest in these items, and major auction houses offer annual (in many cases multiple yearly sales) of Space artifacts and memorabilia.