If you have to ask you are probably far from doing anything.
Three main approaches
1) You emulate the game. If it is something that runs on an old version of DOS or Windows then you can probably run dosbox and get it done. I don't know where the Switch tops out here. Likewise if they were made to run on a console that the Switch can support that is also an option.
2) If the game runs on an interpreted/scripted language (Java, python, lua, ruby, perl, visual basic, in some cases C# and there are plenty more) and that interpreter is available for the Switch (not all of those are, and even those that are might have things missing that the PC has) then yeah. Old PC indie games are an option here as many devs will pick the often nicer to code with scripting languages to make games because they don't need all the 3d power they can muster.
2a) If the game engine is available. For instance many old games back when first person shooter was commonly called Doom clone actually did run using the Doom engine or a tweaked version of it. In the case of some point and click or visual novels you can also often see the engines themselves recreated.
3) If the game has source code (be it leaked, officially released or recreated, official being best for getting people to help as the other two usually run into legal issues) then you then get to see if it is viable to port the game (old games can be quite hard owing to the older coding methods -- see assembly coding, newer games might need more power than the Switch can provide so you then have to figure out if and how you might do it)
https://osgameclones.com/ having a list of this sort of thing (minus various leaked games and games where the source code was taken down again).
You can recreate source code yourself, however it is usually a very hard project that takes skilled coders some years to complete (the https://osgameclones.com/ site will have several that use the remake/recreate approach and you can go read the dev forum discussions/blogs/diaries/requests for help/general progress reports to see how slow and involved it is). PC indie games can be a bit easier than the sorts of things that see EA or something task 100 devs to make and give them millions and a few years. On top of that you would then have to port it to the Switch afterwards.